嗨,我正在一個應用程序工作。當有一個主屏幕有5個按鈕。在每個按鈕的點擊我想要打開與5視圖controllers.tabbar tab.screen屏幕我的意思是當你點擊按鈕tabbar打開。並且在標籤欄視圖中也有後退按鈕。點擊後退按鈕我想要回到主屏幕,反之亦然。 如何做那些傢伙。任何教程,鏈接,示例代碼將不勝感激。如何處理視圖控制器?
非常感謝
嗨,我正在一個應用程序工作。當有一個主屏幕有5個按鈕。在每個按鈕的點擊我想要打開與5視圖controllers.tabbar tab.screen屏幕我的意思是當你點擊按鈕tabbar打開。並且在標籤欄視圖中也有後退按鈕。點擊後退按鈕我想要回到主屏幕,反之亦然。 如何做那些傢伙。任何教程,鏈接,示例代碼將不勝感激。如何處理視圖控制器?
非常感謝
導航堆棧中的Tabbar控制器很複雜。由於每個標籤控制器本身也可以具有導航控制器。
有一個WindowManager
類。它應該同時擁有 - FirstViewController
和 - TabbarController
所有組件和自己應在的WindowManager類實例化的UITabbarControllers。 它的init
可能有這樣的代碼,使兩個tabbarcontrollers類似。
self.tabBarController = [[UITabBarController alloc] init];
self.controllers = [[NSMutableArray alloc] init];
// initialize the view controllers and navigation controllers for the tab bar
self.friendsVC = [[FriendsVC alloc] initWithNibName:@"FriendsView" bundle:nil];
UINavigationController *friendsNVC = [[UINavigationController alloc] initWithRootViewController: friendsVC];
friendsNVC.navigationBar.barStyle = UIBarStyleBlack;
[controllers addObject:friendsNVC];
[friendsNVC release];
self.paymentsVC = [[PaymentsVC alloc] initWithNibName:@"PaymentsView" bundle:nil];
UINavigationController *paymentsNVC = [[UINavigationController alloc] initWithRootViewController: paymentsVC];
paymentsNVC.navigationBar.barStyle = UIBarStyleBlack;
[controllers addObject:paymentsNVC];
[paymentsNVC release];
tabBarController.viewControllers = controllers;
tabBarController.selectedIndex = 0;
tabBarController.delegate = self;
self.view = tabBarController.view;
在WindowManager
,你可以有兩種方法一樣,
[WindowManager showViewController] and
[WindowManager showTabbarController].
- showViewController {
//Initiate View controller and use [self.window addSubView:vc.view];
}
- showTabbarController {
// initiate the tabbar manager
}
你可以有你的第一個的TabBar控制器左側上方的「返回」按鈕,調用
[WindowManager showViewController];
嘿karim泰克你的答案我已經試過這種方式,但問題發生時,我想彈出到主屏幕,它不pop.Firstly我帶着navigationcontroller homeviewcontroller,然後我把它推到tabbar視圖,但是當我點擊標籤欄上的後退按鈕它不會彈出到主視圖。你有任何想法如何流行到家裏查看then.I嘗試調用[self.navigationcontroller poptoviewcontroller:YES];和[self.navigationcontroller.tabbarcontroller poptoviewcontroller:YES];以及 – 2011-05-21 09:58:38
使導航堆棧中的標籤欄控制器不受歡迎並且不受歡迎。我已經更精細地編輯答案來做同樣的事情。 – karim 2011-05-21 10:03:31
是的,我知道這不是好的方法,然後堆棧組織不會好。但是我能以這種方式做客戶想要的。我告訴T.L.它不能這樣做,要麼它需要基於標籤或基於導航。 – 2011-05-21 10:12:24
請你詳細說明一下嗎? – 2011-05-21 09:40:50
Zoozoo,有一個帶有5個按鈕的導航控制器的主屏幕,點擊任何按鈕我想打開基於標籤的應用程序,如有4個選項卡。現在當選項卡視圖到來時,需要有一個後退按鈕,點擊,我想導航回到主屏幕的按鈕。你現在讓我現在 – 2011-05-21 09:45:02