这是我的一份崩溃报告的顶部。 Apple 是否规定了应用程序启动超时限制?如果是这样,有什么常见的解决方法吗?
Elapsed total CPU time (seconds): 13.700 (user 8.580, system 5.120), 67% CPU
Elapsed application CPU time (seconds): 6.180, 30% CPU
在 iPhone 3G 上。
也许我必须拆分/延迟我的启动任务......
我认为它必须在 5(或可能 10)秒内启动,否则 iPhone 会认为它已经崩溃了。
尽量避免在启动时在主线程上加载大量内容。如果您需要加载很多东西,请在后台线程上执行,如下所示:
- (void)startLoading
{
//call this in your app delegate instead of setting window.rootViewController to your main view controller
//you can show a UIActivityIndiocatorView here or something if you like
[self performSelectorInBackground:@selector(loadInBackground)];
}
- (void)loadInBackground
{
//do your loading here
//this is in the background, so don't try to access any UI elements
[self performSelectorOnMainThread:@selector(finishedLoading) withObject:nil waituntilDone:NO];
}
- (void)finishedLoading
{
//back on the main thread now, it's safe to show your view controller
window.rootViewController = viewController;
[window makeKeyAndVisible];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)