2009-10-20 31 views
2

的UITabBarController UINavigationController的与“更多”选项卡中的问题的UITabBarController UINavigationController的用“更多”选项卡发行

有在使用的UITabBarController UINavigationController的一个问题。我有一个TabBar与6项。当然,会出现一个非标准项目“more”,并且有两个UINavigationController不适合TabBar。问题的核心是:当我使用可见项目时(前四个),UIViewController可以在UINavigationController中推送:

[self.navigationController pushViewController:userDataViewController animated:YES];

如果您在“更多”呼吁和重新排列物品以这样一种方式,即一个可见的UINavigationController进入“更多”,就可以在调用时出现userDataViewController。这个userDataViewController是最后一个,它有一个堆栈,一个Back按钮可以回到“更多”,但不是控制器,在userDataViewController出现之前。

我明白,其实选择pushViewController从“多”之称,它在推动一堆我的UINavigationController,这是不好的。也许,有人遇到过这样的问题,可以帮我解决这个问题吗?

谢谢你。

+0

这可能帮助:http://stackoverflow.com/a/38832392/171933 – 2016-08-09 12:43:54

回答

3

一个可能的解决方案是迫使你的UINavigationController返回到它的根视图控制器的用户节省了标签栏配置的变化之前。要做到这一点,实现以下方法在你的标签栏控制器的委托:

- (void)tabBarController:(UITabBarController *)tabBarController willEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed { 
    if (changed) { 
     NSLog (@"User has rearranged tab bar items"); 

     for (UIViewController *controller in tabBarController.viewControllers) { 
      if ([controller isKindOfClass:[UINavigationController class]]) { 
       [((UINavigationController *)controller) popToRootViewControllerAnimated:NO]; 
      } 
     } 
    } 
} 
+2

无意中发现了这个bug今天。这为我修好了。非常感谢Aliaksei,在它工作之前,我不得不添加'tabBarController.delegate = self;',所以注意这一点。 – 2010-09-07 17:38:47

相关问题