【发布时间】:2009-05-11 01:36:43
【问题描述】:
我正在开发一个应用程序,客户想要为大图像 (305x332) 制作动画。客户希望在 1.75 秒内循环播放 50 帧动画。我发现应用程序在处理这么多时非常慢。启动、触摸响应和关机都很慢。在 iPhone 上,应用程序经常会崩溃或锁定手机。请参阅下面的代码。我的问题:
- 我是在做某事导致性能不佳,还是要求 50 帧太多?
- 是否有关于动画帧数和动画速度的最佳做法?
- 动画中的图像大小是否有最佳做法?
请告诉我。这是代码...
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
for(int i = 1; i <= 50; i++)
{
[tempArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"%@-%d-%04d.JPG",[constitution getConstitutionWord], constitution.getAnimationEnum, i]]];
}
backgroundImage.animationImages = tempArray;
[tempArray release];
backgroundImage.animationDuration = 1.75; // seconds
backgroundImage.animationRepeatCount = 0; // 0 = loops forever
[backgroundImage startAnimating];
【问题讨论】: