Share data between two or more iPhone applications

In the sandboxed world of iOS development sharing data between applications can prove difficult Since iOS developers can’t share data directly through the file system, they need to find alternate solutions for their applications. Some common solutions include: UIDocumentInteractionController UIActivityViewController Shared Keychain Access Custom URL Scheme Web Service iCloud API UIDocumentInteractionController: Allows the user to … Read more

iphone/ipad: How exactly use NSAttributedString?

Starting from the iOS 6.0 you can do it like that: NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@”Hello. That is a test attributed string.”]; [str addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(3,5)]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(10,7)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@”HelveticaNeue-Bold” size:20.0] range:NSMakeRange(20, 10)]; label.attributedText = str;

Getting a screenshot of a UIScrollView, including offscreen parts

Here is code that works … – (IBAction) renderScrollViewToImage { UIImage* image = nil; UIGraphicsBeginImageContext(_scrollView.contentSize); { CGPoint savedContentOffset = _scrollView.contentOffset; CGRect savedFrame = _scrollView.frame; _scrollView.contentOffset = CGPointZero; _scrollView.frame = CGRectMake(0, 0, _scrollView.contentSize.width, _scrollView.contentSize.height); [_scrollView.layer renderInContext: UIGraphicsGetCurrentContext()]; image = UIGraphicsGetImageFromCurrentImageContext(); _scrollView.contentOffset = savedContentOffset; _scrollView.frame = savedFrame; } UIGraphicsEndImageContext(); if (image != nil) { [UIImagePNGRepresentation(image) writeToFile: @”/tmp/test.png” … Read more

position: fixed doesn’t work on iPad and iPhone

A lot of mobile browsers deliberately do not support position:fixed; on the grounds that fixed elements could get in the way on a small screen. The Quirksmode.org site has a very good blog post that explains the problem: http://www.quirksmode.org/blog/archives/2010/12/the_fifth_posit.html Also see this page for a compatibility chart showing which mobile browsers support position:fixed;: http://www.quirksmode.org/m/css.html (but … Read more

How can I recognize touch events using jQuery in Safari for iPad? Is it possible?

Core jQuery doesn’t have anything special for touch events, but you can easily build your own using the following events touchstart touchmove touchend touchcancel For example, the touchmove document.addEventListener(‘touchmove’, function(e) { e.preventDefault(); var touch = e.touches[0]; alert(touch.pageX + ” – ” + touch.pageY); }, false); This works in most WebKit based browsers (incl. Android). Here … Read more

How to detect total available/free disk space on the iPhone/iPad device?

UPDATE: Since a lot of time has passed after this answer and new methods/APIs have been added, please check the updated answers below for Swift etc; Since I’ve not used them myself, I can’t vouch for them. Original answer: I found the following solution working for me: -(uint64_t)getFreeDiskspace { uint64_t totalSpace = 0; uint64_t totalFreeSpace … Read more

What is the difference between screenX/Y, clientX/Y and pageX/Y?

Here’s a picture explaining the difference between pageY and clientY. Same for pageX and clientX, respectively. pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling), while clientX/Y coordinates are relative to the top left corner of the visible part of the page, “seen” through browser … Read more

How to hide UINavigationBar 1px bottom line

For iOS 13: Use the .shadowColor property If this property is nil or contains the clear color, the bar displays no shadow For instance: let navigationBar = navigationController?.navigationBar let navigationBarAppearance = UINavigationBarAppearance() navigationBarAppearance.shadowColor = .clear navigationBar?.scrollEdgeAppearance = navigationBarAppearance For iOS 12 and below: To do this, you should set a custom shadow image. But for … Read more