【发布时间】:2010-11-02 06:55:41
【问题描述】:
我正在构建一个应用程序,其中包含许多图像序列(5 个序列,每个序列大约 80 个图像)。它在 iPhone 模拟器中运行良好,但在我测试它时会导致我的 iPhone 重新启动。顺便说一句,每个 png 图像的大小约为 8k。 有没有人成功构建过类似的应用程序? 我是否使用了太多资源让 iPhone 无法处理? 有人吗?
更新:
感谢大家的回答!我修改了我的代码以使用 [UIImage imageWithContentsOfFile:] 而不是 [UIImage imageNamed:]
但是我仍然无法阻止该应用程序使我的 iPhone 崩溃。
(请注意,我的 png 没有那么大,大约 400x400px / 8k)
有人有什么建议吗?
这是我的代码:
// code snippet:
myFrames = [[NSMutableArray alloc] initWithCapacity:maxFrames];
NSMutableString *curFrame;
num = 0;
// loop (maxframes = 80)
for(int f = 1; f < maxFrames+1; f++)
{
curFrame = [NSMutableString stringWithString:tName];
if(f < 10) [curFrame appendString:[NSString stringWithFormat:@"00%i",f]];
else if(f>9 && f<100) [curFrame appendString:[NSString stringWithFormat:@"0%i",f]];
else [curFrame appendString:[NSString stringWithFormat:@"%i",f]];
UIImage *img = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:curFrame ofType:@"png"]];
if(img) [myFrames addObject:img];
[img release];
}
// animate the images!
self.animationImages = myFrames;
self.animationDuration = (maxFrames * .05); // Seconds
[self startAnimating];
【问题讨论】:
标签: iphone objective-c cocoa-touch