开发者

UITabBarController With UINavigationController "more" Tab Issue

UITabBarController with UINavigationController "more" tab issue

There is a problem with using UINavigationController in UITabBarController. I have a TabBar  with 6 items. Of course, a standart item "more" a开发者_StackOverflowppears, and there are two UINavigationControllers that didn't fit in a TabBar. The core of the problem is: when I'm working with visible items (a first four), UIViewController can be pushed  in an UINavigationController:

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

If you call on in "more" and rearrange items in such way, that a visible UINavigationController gets into "more", when calling on it userDataViewController appears.  This  userDataViewController is the last, which has got in a stack and a Back button leads back to "more", but not to the controllers, that were before a userDataViewController appeared.

I understand that in fact a selector pushViewController is called from "more", and it pushes my UINavigationController in a stack, and it's not good. Maybe, someone has faced such problem and could help me to solve it?

Thank you forward.


A possible solution is to force your UINavigationController to return to its root view controller just before a user saves changes of the tab bar configuration. To do that, implement the following method in your tab bar controller's delegate:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜