BUG出现描述
<Error>: ImageIO: CGImageReadCreateDataWithMappedFile 'open' failed '路径'
error = 2 (No such file or directory)
BUG出现操作还原
1.从本地沙盒读取图片,加载到UIimageViews上。
2.删除沙盒里的图片。
3.将UIImageView里的图片保存到本地沙盒时,BUG出现。
BUG出现原因解析与解决方法
原因:保存时,图片已经不存在了,所以保存失败。
解决方案:从路径读取图片后,先转换成NSData,再生成一张新的image,之后保存就OK。
UIImage *tempImage = [[UIImage alloc] initWithContentsOfFile:path];
NSData *tempData = UIImageJPEGRepresentation(tempImage, 1.0);
UIImage *newImage = [UIImage imageWithData:coverData];
这样用newImage保存就不会出现问题了。