【发布时间】:2013-12-29 13:25:07
【问题描述】:
我正在制作一本 iPad 杂志,我正在使用大量图像(背景、幻灯片和动画),并且占用的内存非常高。
我看过下面的方法会占用大量内存
UIImage *picture = [UIImage imageNamed:@"myFile.png"];
他们推荐使用这个
NSString *fullpath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/myFile.png"];
imageView.image = [UIImage imageWithContentsOfFile:fullpath];
但我也找到了另一种方法
imageView.image = [[UIImage alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"myFile" ofType:@"png"]];
为了优化我的应用,我应该使用哪种方法?我所有的图像都是 .jpg 并在 Photoshop 中保存为网络。
【问题讨论】:
-
“我读过以下方法使用大量内存”本身并不正确。此外,这与 Xcode 无关。
标签: ios image ipad memory optimization