2012-03-10 66 views
3

我知道,如果我有RootViewController的與的TabBar開始我可以這樣創建UITabBar:的UITabBarController委託與故事板

UITabBarController *tabController = (UITabBarController *)self.window.rootViewController; 
tabController.selectedIndex = [defaults integerForKey:kOptionLastTabSelectedKey]; 
tabController.delegate = self; 

但我的問題是:如何創建的TabBar如果使用TabBar不是我rootView?我的應用程序從簡單的viewController登錄開始,登錄後將出現tabBar。 其次,我應該在哪裏創建標籤欄,在appDelegate或其他?

謝謝!!!

回答

0

我認爲你應該讓你的tabBarController成爲rootViewController到你的窗口,而不是將你的loginViewController模態地顯示在窗口rootViewController上,登錄後你可以關閉loginViewController。檢查下面的代碼。

[self.window.rootViewController presentModalViewController:loginViewController animated:YES]; 

並在登錄後使用委託方法或在loginViewController類中編寫以下代碼並關閉loginViewController。

[self.window.rootViewController dismissModalViewControllerAnimated:YES]; 

[self dismissModalViewControllerAnimated:YES];