特定于应用程序的信息:应用程序未能及时启动(iOS)?

时间:2012-02-11 14:37:30

标签: iphone ios launch

这是我的一个崩溃报告的顶部。是否有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上。

我必须分开/延迟我的启动任务......

1 个答案:

答案 0 :(得分:10)

我认为它必须在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];
}