简体   繁体   中英

UITabbarController with MoreNavigationController , PoptoRootViewController issue

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.

在此处输入图片说明

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];
}

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM