2013-02-13 94 views
2

我想通過登錄請求可視化一個UIViewController。 登錄後(如果可以)我想顯示我的應用程序,它由具有各種選項卡的UITabBarController組成。 現在,我通常是在AppDelegate中使用此代碼來管理的UITabBarController:用於UITabBarController之前登錄的UIViewController

UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil]; 
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; 

self.tabBarController = [[UITabBarController alloc] init]; 
self.tabBarController.viewControllers = @[viewController1, viewController2]; 
self.window.rootViewController = self.tabBarController; 
[self.window makeKeyAndVisible]; 

,這將顯示出我的應用程序。在此之前,如何顯示一個用於登錄請求的UIViewController?

回答

1

1.一種方法是使您的登錄控制器成爲根視圖控制器並從其中將視圖控制器從其中推出。您可以在應用程序啓動過程中檢查登錄並直接跳到沒有動畫的標籤欄控制器。

2.或者,您可以使用疊加層覆蓋標籤欄控制器(向窗口添加子視圖)。然後在需要的情況下顯示登錄控制器的視圖,或者使疊加層立即消失。

+0

嗨,謝謝你的回覆....我已經用這種方式解決了...在正確的登錄後,我將這段代碼稱爲: homeViewController * controller = [[homeViewController alloc] initWithNibName:@「homeViewController」bundle:nil ]。 UITabBarController * tabBarController = [[UITabBarController alloc] init]; tabBarController.viewControllers = [NSArray arrayWithObjects:controller,nil]; tabBarController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentViewController:tabBarController animated:YES completion:nil]; – Blasco73 2013-02-16 13:43:48

+0

太棒了,很高興我能幫上忙。請不要忘記勾選複選標記。 – Mundi 2013-02-17 15:32:53

相關問題