2011-07-11 80 views
0

我是iPhone開發新手...現在我試圖構建一個應用程序,其中用戶首先顯示登錄屏幕。在這個視圖中沒有導航控件。如何將uitabbarcontroller作爲子視圖添加到UIViewController中

一旦用戶登錄,我想顯示一個新的視圖,其中有tabbar控制。根據tabbar中選定的標籤項目...正在顯示的視圖可能只有一個表格視圖或表格視圖+導航欄控件。

對此可以做任何幫助嗎?

我能夠構建一個小應用程序登錄屏幕和驗證用戶憑據。 另外一個不同的應用程序,我建立一個tabbarviewcontroller和顯示關聯各個視圖到每個tabbar項目。

,但不知道到both.So結合的問題是,我不知道如何添加的UITabBarController作爲第二視圖

請幫我在這。

回答

0

你需要做這樣的事情。從主窗口和tabbarcontroller的視圖中刪除登錄視圖到主窗口。你只需要在應用程序委託類中實現一些方法。

+0

對不起,我不能清楚地知道它...你能請解釋一下代碼片段嗎? – itdeeps

0

將tabbatcontroller添加到您的mainwindow類。每當你需要tabar在應用程序。只需刪除UINavigationController並添加UITabBarController。

或者添加tabbatcontroller到你的mainwindow類,並且只從當前viewcontroller出現tababrcontroller。

AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate]; 
delegate.tCtr.selectedIndex = index; 
delegate.tCtr.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
[self presentModalViewController:delegate.tCtr animated:YES]; 
+0

感謝您的回覆..我會嘗試這個... – itdeeps

+0

它在控制檯顯示錯誤..其實我按照你說的做,但在控制檯它顯示「終止應用程序由於未捕獲的異常'NSInvalidArgumentException',原因:' - [UIApplication tabBarController]:無法識別的選擇器發送「..你有什麼想法?我的代碼是:testTabAppDelegate * del =(testTabAppDelegate *)[UIApplication sharedApplication]; \t del.tabBarController.selectedIndex = 1; \t del.tabBarController.modalTransitionStyle = UIModalTransitionStyleFlipHorizo​​ntal; \t [self presentModalViewController:del.tabBarController animated:YES]; – itdeeps

+0

你給tababr連接del? –

相關問題