将UITabBarController推送到另一个UITabBarController

时间:2015-01-09 03:07:32

标签: ios uitabbarcontroller tabbar

UINavigationController的根目录中有UITabBarController。我还有另一个UITabBarController我在现有的UITabBarController之上。

然而,当我这样做时,我所呈现的UITabBar中的UITabBarController并未被推到原始UITabBarController的现有{{1}}之上。有没有办法获得这个功能?

2 个答案:

答案 0 :(得分:5)

首先,你需要参考root viewController(UINavigationController) 像

   UINavigationController *rootController = self.tabBarController.navigationController;

或者,如果您在tabbar中添加了导航控制器。 那么

   UINavigationController *rootController = self.navigationController.tabBarController.navigationController;

现在,创建要推送的控制器对象。

UITabBarController *tabbarController; 

并推入根控制器

[rootController  pushViewController:tabbarController animated:YES];

答案 1 :(得分:2)

从你的问题来看,这就是我所假设的。

  1. 第一个VC是TableView Controller,它是根VC。
  2. 哪个需要推TabBar VC。
  3. 哪个可以进一步推送到tableViewController。
  4. StoryBoard配置 enter image description here

    模拟器输出 enter image description here