The entire block of code 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 is the one causing the problem:
[webview.layer renderInContext:UIGraphicsGetCurrentContext()];
The app crashes with no reason listed in the console, and using @try @catch @finally comes up with nothing. I imported Quartzcore in AppDelegate.h, if that has anything to do with it. The app works fine in the simulator, but crashes when run on a real device.