这是模拟器的屏幕截图和保存的图像:
代码 :
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。