Disabling user selection in UIWebView

Here are a few ways to disable selection: Add the following to your mobile web documents <style type=”text/css”> * { -webkit-touch-callout: none; -webkit-user-select: none; /* Disable selection/copy in UIWebView */ } </style> Programmatically load the following Javascript code: NSString * jsCallBack = @”window.getSelection().removeAllRanges();”; [webView stringByEvaluatingJavaScriptFromString:jsCallBack]; Disable the Copy / Paste user menu: – (BOOL)canPerformAction:(SEL)action withSender:(id)sender … Read more

Why rename synthesized properties in iOS with leading underscores? [duplicate]

This is an artifact of a previous version of the Objective-C runtime. Originally, @synthesize was used to create accessors methods, but the runtime still required that instance variables had to be instantiated explicitly: @interface Foo : Bar { Baz *_qux; } @property (retain) Baz *qux; @end @implementation Foo @synthesize qux = _qux; – (void)dealloc { … Read more

How can we programmatically detect which iOS version is device running on? [duplicate]

Best current version, without need to deal with numeric search within NSString is to define macros (See original answer: Check iPhone iOS Version) Those macros do exist in github, see: https://github.com/carlj/CJAMacros/blob/master/CJAMacros/CJAMacros.h Like this: #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] … Read more

How do you use NSAttributedString?

When building attributed strings, I prefer to use the mutable subclass, just to keep things cleaner. That being said, here’s how you create a tri-color attributed string: NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@”firstsecondthird”]; [string addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0,5)]; [string addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(5,6)]; [string addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(11,5)]; typed in a browser. caveat implementor Obviously … Read more