【发布时间】:2014-04-06 11:12:45
【问题描述】:
在我的应用加载并显示其启动屏幕后,我正在制作一个简单的 png 动画。动画在模拟器中有效,但在实际 iPhone 上无效,因为内存压力而终止(虽然启动屏幕确实首先加载)。在调试中,内存呈指数增长到 200MB,直到崩溃。仪器显示没有泄漏,所有堆和匿名 Vm 总体为 9.61 MB。动画在实际 iPhone 上根本不显示。
我已经停止使用 imageNamed 来设置动画图像,并按照另一个帮助主题的建议使用 imageFilePath。它可以工作并且图像会加载到模拟器上。我只是不确定还能做什么。非常感谢您的帮助。
在 didFinishLaunchingWithOptions 中:
[self.window makeKeyAndVisible];
self.animationView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];
NSArray *animationArray = [[NSArray alloc] initWithObjects:
[UIImage imageFromMainBundleFile:@"/Splash_00000.png"],
[UIImage imageFromMainBundleFile:@"/Splash_00001.png"],
//大概有150个,剩下的就省略了
nil];
self.animationView.animationImages = animationArray;
self.animationView.animationDuration = 5.0f;
self.animationView.animationRepeatCount = 1;
[self.animationView startAnimating];
[self.window addSubview:self.animationView];
[self.window bringSubviewToFront:self.animationView];
如果需要,这是我从另一个线程得到的方法:
+(UIImage*)imageFromMainBundleFile:(NSString*)aFileName
{
NSString* bundlePath = [[NSBundle mainBundle] bundlePath];
return [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@", bundlePath, aFileName]];
}
【问题讨论】:
-
“大约有 150 个”。那就是你的问题。
标签: ios objective-c xcode animation memory