1
下面是从模拟器截图并保存图像:UIImage的节能问题iOS7:混合问题
编号:
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//guru - just for simulator
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Image.png"];
[UIImagePNGRepresentation(screenshotImage) writeToFile:filePath atomically:YES];
//end guru
UIImageWriteToSavedPhotosAlbum(screenshotImage, nil, nil, nil);
我怎样才能解决这个问题?当我使用Xcode4_iOS6构建时效果很好,但不适用于Xcode5_iOS7。
其工作。谢谢 – Guru
IS_IOS_7真的有必要吗?您可以使用if(UIGraphicsBeginImageContextWithOptions!= NULL)在所有支持它的操作系统版本上利用该方法。 –
是的,这是有效的。 – iPhoneProcessor