iOS 8 Snapshotting a view that has not been rendered results in an empty snapshot

I’m pretty sure this is just a bug in iOS 8.0. It’s reproducible with the simplest of POC apps that does nothing more than attempt to present a UIImagePickerController like you’re doing above. Furthermore, there’s no alternative pattern to displaying the image picker/camera, to my knowledge. You can even download Apple’s Using UIImagePickerController sample app, … Read more

NSRange to Range

As of Swift 4 (Xcode 9), the Swift standard library provides methods to convert between Swift string ranges (Range<String.Index>) and NSString ranges (NSRange). Example: let str = “a👿b🇩🇪c” let r1 = str.range(of: “🇩🇪”)! // String range to NSRange: let n1 = NSRange(r1, in: str) print((str as NSString).substring(with: n1)) // 🇩🇪 // NSRange back to String … Read more

Reading in a JSON File Using Swift

Follow the below code : if let path = NSBundle.mainBundle().pathForResource(“test”, ofType: “json”) { if let jsonData = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: nil) { if let jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(jsonData, options: NSJSONReadingOptions.MutableContainers, error: nil) as? NSDictionary { if let persons : NSArray = jsonResult[“person”] as? NSArray { // Do stuff } } } } The … Read more

Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0

Update 3: This warning can also be triggered by labels that have numberOfLines set to anything but 1 if your deployment target is set to 7.1. This is completely reproducible with new single-view project. Steps to Reproduce: Create a new single-view, objective-c project Set the Deployment Target to 7.1 Open the project’s storyboard Drop a … Read more

Capture iOS Simulator video for App Preview

For Xcode 8.2 or later You can take videos and screenshots of Simulator using the xcrun simctl, a command-line utility to control the Simulator Run your app on the simulator Open a terminal Run the command To take a screenshot xcrun simctl io booted screenshot <filename>.<file extension> For example: xcrun simctl io booted screenshot myScreenshot.png … Read more

Location Services not working in iOS 8

I ended up solving my own problem. Apparently in iOS 8 SDK, requestAlwaysAuthorization (for background location) or requestWhenInUseAuthorization (location only when foreground) call on CLLocationManager is needed before starting location updates. There also needs to be NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key in Info.plist with a message to be displayed in the prompt. Adding these solved my … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)