在我的iPad应用程序中,我使用ALAsset并使用以下代码从Photo Stream加载100张图像:
ALAsset *asset = [assets objectAtIndex:[sender tag]];
ALAssetRepresentation *representation = [asset defaultRepresentation];
UIImage *image = [[UIImage alloc] initWithCGImage:[representation fullScreenImage]
scale:1.0f
orientation:0];
一切都很完美。但是当我将它作为JPEG文件缓存到文件系统,然后再次使用UIImage *image = [UIImage imageWithContentsOfFile:fullPath]
加载它们时,应用程序崩溃了内存警告,我可以在分析器中看到它确实使用了大量的RAM。
为什么会这样?
答案 0 :(得分:1)
一件事,
从图库加载图片时,为什么不存储AssetURL
,而不是UIImage
;这应该占用更少的空间并提高速度。
当您需要显示时,可能使用缩略图表示?
答案 1 :(得分:0)
好的,这是我的坏事。我发现了问题,而且在任何情况下都会出现内存问题。 ALAsset
和imageWithContentsOfFile
的工作方式完全相同。
现在我将尝试找到减少每张图片尺寸的方法。