2010-09-21 83 views
2

在我的應用程序中出現了一個奇怪的問題,它在加載我的啓動畫面之前顯示黑屏一段時間。這個黑屏並不是由於任何正在進行的操作,因爲我正在加載我的splashscreen,然後開始我的XML解析任務。我的啓動畫面加載之前的黑屏iphone

我甚至嘗試過使用[window makeKeyAndVisible];但徒勞無功。

這我的代碼:

- (void)applicationDidFinishLaunching:(UIApplication *)application 
{  
    comingFromLogin = NO; 
    //Check For Internet 
    gotInternet = [self checkInternet]; //Test for Internet, calling the self method 
    if (gotInternet == 0) 
    { 
     //I have no internet 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry No Network Available" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
     [alert show]; 
     [alert release]; 
     // internetIcon.hidden = NO; 
    } 
    else 
    { 
     //I do have internet 
     [self didLoadSplashScreen]; 
    } 
} 

-(void)didLoadSplashScreen 
{ 
    activity_indicator = [[ActivityIndicator alloc]initWithNibName:@"ActivityIndicator" bundle:nil]; 
    splashScreen = [[splashScreenView alloc]initWithNibName:@"splashScreenView" bundle:nil]; 

    splashScreen.view.alpha = 1.0; 
    splashScreen.view.frame = CGRectMake(0, 20, 320, 480); 
    [window addSubview:splashScreen.view]; 
    [window addSubview:activity_indicator.view]; 

    [window makeKeyAndVisible]; 
    [self disappearSplashScreen]; 
} 

任何人可以請幫助?

此黑屏停留約2秒鐘。我在iOS4上運行它。

Thanx提前。

回答

6

這是默認的加載行爲! applicationDidFinishLaunching方法不會運行,直到應用程序FINISHED LOADING完成。

解決這個問題的方法是將圖片的大小視爲Default.png而不是黑屏。