The entire code block consists of the following:
CGSize layerSize = [webview sizeThatFits:CGSizeZero]; if ([UIScreen instancesRespondToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0f) { UIGraphicsBeginImageContextWithOptions(layerSize, NO, 2.0f); } else { UIGraphicsBeginImageContext(layerSize); } [webview.layer renderInContext:UIGraphicsGetCurrentContext()]; screenshot = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
but after testing this line causes a problem:
[webview.layer renderInContext:UIGraphicsGetCurrentContext()]
The application shuts down for no reason listed in the console, and using @try @catch @finally fails. I imported Quartzcore into AppDelegate.h if this has anything to do with it. The application works fine in the simulator, but it crashes when working on a real device.
source share