我从网络服务器下载jpeg图片并将其加载到UIImage。
如果我直接在UIImageView中显示UIImage,我会正确看到图片。
但是,如果我将图像缓存到文件: [UIImageJPEGRepresentation(image,1.0f)writeToFile:sFilePath atoimcally:YES] 并加载:
image=[UIImage imageWithContentsOFile:sFilePath]
and display this in the same UIImageView, I can see white stripes in the sides of the picture.
再次,完全相同的UIImageView对象,其中包含相同的属性设置。
为什么?
答案 0 :(得分:2)
您只需将从网络加载的NSData
写入文件,而无需通过UIImageJPEGRepresentation
例程。
[dataObject writeToURL:fileURL atomically:YES];
并检索
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[fileURL path]];
在我的应用中效果非常好。