我试图运行两个UImageViews有多个动画数组,他们根据用户的选择加载和动画。例如,下面是一个方法:iOS - UIImageView动画接收内存警告
-(void)initiateAnimations {
nullAnimation = [NSArray arrayWithObjects:
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"null0002" ofType:@"png"]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"null0003" ofType:@"png"]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"null0004" ofType:@"png"]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"null0005" ofType:@"png"]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"null0006" ofType:@"png"]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"null0007" ofType:@"png"]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"null0008" ofType:@"png"]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"null0009" ofType:@"png"]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"null0010" ofType:@"png"]], nil];
}
这里是一个IBAction
调用动画制作方法:
-(IBAction)nullani {
player.animationImages = nullAnimation;
player.animationDuration = 0.50;
player.animationRepeatCount = 1;
[player startAnimating];
}
这一切运作良好,在第一,但请记住,我有大约5-6其他大致具有相同尺寸图像的动画数组。他们不是很大,范围从12-80k.png文件。我收到此消息,任何新的动画加载会崩溃的应用程序后
2013-03-16 01:34:44.438 [3316:907] Received memory warning.
:当我尝试了几次后,动画,我在输出recieving此错误。 我通过Instruments运行它,无法找到任何泄漏,并且输出在崩溃时不会给我带来任何影响。
这里是否有任何内存问题?我如何摆脱这个问题?谢谢。
图像有多大?磁盘上的大小不能以kb为单位,如.png文件。像素?请记住,要显示图像,他们需要解压缩,所以它可能没有太多关于12-80k大小。这些全屏图像? – Nate 2013-03-16 08:50:42
请记住,泄漏的内存不是您内存不足的唯一方法。你可以使用太多。仪器告诉你有关内存使用情况的内容?每次启动动画时,您使用了多少个字节? – jrturton 2013-03-16 08:55:40
@Nate正常大小是800x800,视网膜1600x1600。它大部分是空白的,主要内容大约是75x400,因为我有动画增长/缩小/扩展。 800x800就像一个舞台。 – nworksdev 2013-03-16 08:57:02