UITabbarController with MoreNavigationController , PoptoRootViewController issue

只谈情不闲聊 提交于 2019-12-07 09:46:07

问题


Kindly help me with this issue .

I am using tabbarcontroller in my App,

[tabBarController setViewControllers:tabs]; tabs Contain array of viewcontrollers (6 viewcontrollers).

It automatically created more button.

ISSUE

When I open any viewcontroller from more button and then open any other controller from index 0 to 2 , and then press more button it maintain the last opened viewcontroller .

For Example: more button tableviewcontroller

screen :

Now when i press Contacts let say

Now when user press any other tabbar like feature tab bar

Now when user go back to more tab it shows the contact's viewcontroller

But i want the app to poptorootviewcontroller when user back again to more tabbar , and simply more tableviewcontroller.


回答1:


You can do this by in the ViewWillDisappear method of view controller in More tab, call method to pop this view out of MoreViewNavigationController, like this:

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



回答2:


May be too late but here it is for future reference

UITabController has a tabBar property and it has a delegate which tells you when a tabitem is tapped

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

Tab bar also has another property "items" which lists the visibile tabs. Find the index of the selected tab item in items in the delegate method implementation and if the index is 4 which is more button then call tab [controller.moreNavigationController popToRootViewController]



来源:https://stackoverflow.com/questions/10793905/uitabbarcontroller-with-morenavigationcontroller-poptorootviewcontroller-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!