【发布时间】:2011-04-02 22:08:10
【问题描述】:
我正在使用滑块的值将图像加载到 UIImage 中(如果您愿意,这些是页面或幻灯片)。这个 UIImage 使用滑块非常快速地切换它们。问题是,在某些时候,应用程序在设备上崩溃并出现以下错误:
2011-04-02 17:39:01.836 Book1[2123:307] 收到内存警告。等级=1
代码如下:
- (IBAction)slidePages:(id)sender{
int sliderValue = pageSlider.value;
NSString *slideToPage = [NSString stringWithFormat:@"P%i.jpg", sliderValue];
imagePlaceholder.image = [UIImage imageNamed:slideToPage];
pageDisplay.text = [NSString stringWithFormat:@"Page %i", sliderValue];
currentPage = sliderValue;
}
我能做些什么来提高效率吗?也许错误在其他地方,但我猜它与图像的快速加载有关。
不过,我不知道 iOS 是如何处理这个问题的。每次我将新图像加载到 UIImage 中时,“未加载”的图像会发生什么?
提前致谢。
【问题讨论】:
标签: iphone cocoa-touch ios ipad