0
我想救我的設備以這種方式以後使用的截圖:加載保存的UIImage
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//NSString *tmpPngFile = [NSTemporaryDirectory() stringByAppendingPathComponent:@"background55667.png"];
NSString *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/background55667.png";
[UIImagePNGRepresentation(image) writeToFile:pngPath atomically:YES];
...但我不能似乎能夠在打開它並顯示它的UIImageView。像這樣:
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
// Write out the contents of home directory to console
NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
UIImage *image = [UIImage imageNamed:....];
backGroundPhoto.image = image;
我該怎麼辦?