この方法で後で使用するために、デバイスのスクリーンショットを保存しようとしています。
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;
どうすればいいですか?