【发布时间】:2012-04-04 08:42:31
【问题描述】:
(对不起我的英语)
我需要将图像保存在应用程序路径中,然后在 ImageView 上加载图像。
获取应用路径:
NSString * imagePath = NSHomeDirectory();
imagePath = [imagePath stringByAppendingPathComponent:@"/image.png"];
之后,保存图片:
NSData *imageData = UIImagePNGRepresentation(self.imageView.image);
[imageData writeToFile:self.imagePath atomically:YES]
加载保存在应用路径上的图片
self.imageSaved.image = [UIImage imageWithContentsOfFile:self.imagePath];
问题是图像没有保存到路径中
问候
编辑:
问题解决了,只需要修改文件路径
[imagePath stringByAppendingPathComponent:@"Documents/image.png"];
感谢您的回答。
【问题讨论】: