UITabbarController与MoreNavigationController,PoptoRootViewController问题

时间:2012-05-29 06:10:30

标签: iphone ios ipad uitabbarcontroller

请帮我解决这个问题。

我在我的应用程序中使用tabbarcontroller,

[tabBarController setViewControllers:tabs]; tabs包含viewcontrollers数组(6个viewcontrollers)。

它会自动创建更多按钮。

问题

当我从更多按钮打开任何视图控制器然后从索引0到2打开任何其他控制器,然后按更多按钮它保持最后打开的视图控制器。

例如: 更多按钮tableviewcontroller

屏幕:enter image description here

现在,当我按下联系人时,请说

enter image description here

现在,当用户按任何其他标签栏时,如功能标签栏

enter image description here

现在,当用户返回更多标签时,它会显示联系人的viewcontroller enter image description here

但是当用户再次返回更多标签栏时,我希望应用程序能够poptorootviewcontroller,还有更多的tableviewcontroller。

enter image description here

2 个答案:

答案 0 :(得分:2)

你可以在更多标签中的视图控制器的ViewWillDisappear方法中执行此操作,调用方法从MoreViewNavigationController中弹出此视图,如下所示:

- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController popViewControllerAnimated:NO];
}

答案 1 :(得分:0)

可能为时已晚,但这是为了将来参考

UITabController有一个tabBar属性,并且有一个委托,告诉您何时点击tabitem

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item 

标签栏还有另一个属性“items”,列出了visibile标签。在委托方法实现中的项目中查找所选标签项的索引,如果索引是4,则更多按钮,然后调用选项卡[controller.moreNavigationController popToRootViewController]

相关问题