2013-04-07 54 views
0

對於我的手機應用程序,我希望在3次轉換期間在第一個屏幕中顯示圖像,並在沒有用戶操作的情況下切換到主菜單。iOS:第一屏顯示圖像

如何執行速度並自動切換視圖?

謝謝。

+0

只有使用[標籤:Xcode中]標籤有關IDE本身的問題。 – Undo 2013-04-07 01:40:28

回答

1

你想要做的就是所謂的閃屏是什麼, 見App Launch (Default) Images 或涉及本guide

+0

但是你無法控制顯示啓動圖像的時間 – arnoapp 2013-04-07 00:33:26

+1

是的這種方法你不能顯示大約1秒,但我引用了指南,因爲它很容易遵循 – Anon957 2013-04-07 01:39:52

+3

你可以調用'sleep(3 )'在'applicationDidFinishLauching'中,以便在顯示主視圖之前等待3秒鐘 – 2013-04-07 02:51:41

1

使用此

[self performSelector:@selector(loadMainView) withObject:nil afterDelay:3.0]; 

loadMainView方法,你應該開始設定通常的看法

0

我通常通過創建一個視圖控制器來實現這一點,該視圖控制器在視圖中具有啓動圖像的UIImageView。

使用模式

您可以將其顯示爲以這種方式你RootViewController的頂部的模式視圖控制器。 在AppDelegate中的application:didFinishLaunchingWithOptions:通過調用

// rootViewController is the view controller attached to the UIWindow 
[rootViewController presentViewController:imageViewController animated:NO completion:nil]; 

的imageViewController內呈現模式,你可以這樣做:

- (void)dismiss { 
    // You can animate it or not, depending on your needs 
    [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];  
} 

- (void)viewDidApper { 
    [self performSelector:@selector(dismiss) withObject:nil afterDelay:AMOUNT_OF_TIME]; 
} 

作爲一個UINavigationController堆棧

的第一控制器沒有按類似的方式不涉及模式是在您的UINavigationController中推送此視圖控制器(如果您使用它)

在AppDelegate中的application:didFinishLaunchingWithOptions:你必須有這樣的事情

UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:imageViewController]; 
self.window.rootViewController = navController; 
[self.window makeKeyAndVisible]; 

裏面的imageViewController你可以做到這一點設置導航控制器的第一控制器:

- (void)dismiss { 
    // Here you should init your nextViewController, the real "home" of the app 
    .... 

    // Then you can present it. You can animate it or not, depending on your needs. 
    // I prefer to replace the whole stack, since user shouldn't go back to the image screen. 
    [self.navigationController setViewControllers:@[nextViewController] animated:YES];  
} 

- (void)viewDidApper { 
    [self performSelector:@selector(dismiss) withObject:nil afterDelay:AMOUNT_OF_TIME]; 
}