I have a UITabBar application with 8 tabs in my iPhone app.

  1. When I click on 'More' option, I get the remaining tabs and I navigate to the respective view.
  2. If I click on the visible 2nd or 3rd tab and go back to the 'more' tab, I should again see the table of remaining tab options instead of the navigated subView.

So how shall I reset back to the 'more' tab table everytime 'more' is clicked?

I tried the following delegate method in AppDelegate.m

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    NSLog(@"controller class: %@", NSStringFromClass([viewController class]));
    NSLog(@"controller title: %@", viewController.title);


    if (viewController == tabBarController.moreNavigationController)
    {
        tabBarController.moreNavigationController.delegate = self;
    }
    if ([viewController isKindOfClass:[UINavigationController class]])
    {
        [(UINavigationController *)viewController popToRootViewControllerAnimated:NO]; //All viewControllers are UINavigationController classes in my app
    }

}
有帮助吗?

解决方案

@property(nonatomic, readonly) UINavigationController *moreNavigationController

is responsible for the navigation at the More item, you need to use it when you want to navigate to the root of the item:

[tabBarController.moreNavigationController popToRootViewControllerAnimated:NO];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top