2013-09-24 65 views
0
  1. 首先我直接安裝TabBarController作爲窗口的根視圖控制器,並在viewControllers中有一個NavigationController。
  2. 當應用程序運行,我推了一些新的視圖 - 控制到導航堆棧
  3. 比我點擊導航tabbaritem的navigationController poptoRootViewController

我如何崩潰的第3步事件或停止彈出根?click navigation tabbaritem popToRootViewController

我的解決方法,停止自動彈出到根視圖 - 控制:

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 
UITabBarController *tbc = [[UITabBarController alloc]init]; 

tbc.viewControllers = [NSArray arrayWithObjects:rvc,nil]; 

tbc.delegate = self;} 
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{ 

if([tabBarController selectedViewController] == viewController) 
    return NO; 
return YES;} 

如果你有一個花葯的解決方案,惠康寫下來。

+0

查看http:// stackoverflow.com/questions/6585899/tab-bar-second-tap-pops-to-navigation-controller-how-to-stop-it –

+0

感謝您的鏈接 –

回答

0

嘗試在標籤欄應用程序的代碼

[self.tabBarController.navigationController popToRootViewControllerAnimated:YES]; 
+0

抱歉,我的意思是停止導航控制器popToRootViewController時,我雙擊導航的tabbarItem。感謝您的答案 –

0

您實現新的viewController(推到新的viewController)

進口UITabBarControllerDelegate didSelectViewController方法,

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.tabBarController.delegate = self; 
} 
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController 
{ 
    [self.tabBarController.navigationController popToRootViewControllerAnimated:YES]; 
} 
+0

thans您給我一個idear.i已解決。 –

+0

我的解決方案阻止自動彈出到根視圖控制器: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions UITabBarController * tbc = [[UITabBarController alloc] init]; tbc.viewControllers = [NSArray arrayWithObjects:rvc,nil]; tbc.delegate =自我;} - (BOOL)tabBarController:(的UITabBarController *)tabBarController shouldSelectViewController:(的UIViewController *)的viewController { 如果([tabBarController selectedViewController] ==的viewController) 返回NO; 返回YES;} –