UITabBarController with UINavigationController "more" Tab issue

UITabBarController with more tab option in UINavigationController

There is a problem using the UINavigationController in the UITabBarController. I have a TabBar with 6 items. Of course, the standard more element appears, and there are two UINavigationControllers that don't fit into the TabBar. Core of the problem: when I work with visible items (the first four) the UIViewController can be clicked in the UINavigationController:

[self.navigationController pushViewController: userDataViewController animated: YES];

If you call "greater than" and rearrange items so that the visible UINavigationController falls into "greater than", when you call it, the userDataViewController appears. This userDataViewController is the last one to have a stack, and the back button returns "more", but not to the controllers that were before the userDataViewController existed.

I understand that in fact the pushViewController selector is being called from "more" and it is pushing my UINavigationController onto the stack, which is not good. Maybe someone came across such a problem and could help me solve it?

Thank you, go ahead.

+2


source to share


1 answer


A possible solution is to force your UINavigationController to return to the root view controller just before the user saves the changes to the tab bar settings. To do this, in your tab of the tab bar controller, run the following method:



- (void)tabBarController:(UITabBarController *)tabBarController willEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed {
    if (changed) {
        NSLog (@"User has rearranged tab bar items");

        for (UIViewController *controller in tabBarController.viewControllers) {
            if ([controller isKindOfClass:[UINavigationController class]]) {
                [((UINavigationController *)controller) popToRootViewControllerAnimated:NO];
            }
        }
    }
}

      

+3


source







All Articles