2012-02-11 10 views
4

これは私のクラッシュレポートの1つです。アップルによって決められたアプリの起動タイムアウト制限はありますか?もしあれば、一般的な回避策?アプリケーションの特定情報:アプリケーションは時間内に起動できませんでした(iOS)?

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)秒以内に起動することがあると思い

答えて

10

を/分割多分私の起動作業を遅らせるために持っているか、iPhoneは、それがクラッシュした前提としています。

起動時にメインスレッドにたくさんのものを読み込まないようにしてください。あなたは多くのものをロードする必要がある場合は、このように、バックグラウンドスレッドでそれを行う:私は実際にUIActivityIndi​​catorでDefault.pngを示す「入口」ビューコントローラを作っ

- (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]; 
} 
+0

、そして上の意見の残りの部分をLAOD最終的なコールバック。 – Geri

+0

良いアプローチのように聞こえます。 –

+0

上記のコードに気付かなかった人のためのちょっとした注意....あなたは**メインスレッドでUIKitとやりとりする必要があります**あなたが現在バックグラウンドスレッドにいれば 'performSelectorOnMainThread: 'のようになります。 –

関連する問題