2011-10-04 107 views
1

我目前正在嘗試向我的Splashscreen添加活動指示器視圖。它只應該出現一次 - 在應用程序的第一個開始。某些圖像是爲App創建的,但需要一些時間。向Splashscreen添加子視圖

創建圖像時,Splashscreen仍然可見。所以我認爲可以添加一個Activity Indicator作爲Splashscreen的子視圖,或者至少通過Splashscreen添加它。

有沒有可能使這成爲可能?

感謝您的幫助提前。

回答

3

您需要將「Splashscreen」作爲最頂層的視圖添加到您的窗口中,它自身的「splashcreen」不是視圖。系統將顯示default.png:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    // Override point for customization after application launch. 

    splashScreen = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, -20.0f, 320.0f, 480.0f)]; 
    splashScreen.backgroundColor = [UIColor blackColor]; 
    splashScreen.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"]]; 
    [self.window addSubview:splashScreen]; 

    [self.window makeKeyAndVisible]; 

    [self performSelector:@selector(applicationDidStart) withObject:nil afterDelay:0.1]; 

    return YES; 
} 

splashScreen是一個類變量,您可以將一個活動指示器添加到splashView。

然後在applicationDidStart並啓動方法地方,需要一定的時間的代碼:我不

- (void) applicationDidStart { 
    // some thing that takes a while 

    [splashScreen removeFromSuperView]; 
    [splashScreen release], splashScreen = nil; 
} 
+0

我想他是指「啓動畫面」時的啓動圖像。雖然你可能是對的,我的看法可能是錯誤的。 –

+0

這是添加引號到「SplashScreen」;) – rckoenes

+0

右..「SplashScreen」:D :) –

1

認爲這是可能的一個子視圖添加到啓動畫面。

有一種解決方法,您可以在applicationDidFinishLaunching上推送中間視圖,並使視圖的背景圖像與啓動屏幕相同。

現在,您可以完成在此視圖上創建圖像的內容。

一旦圖像被創建,調用applicationDelegate中的方法將彈出中間視圖並添加常規視圖。

希望這可以幫助你。