I have an app which has three tabs in tab bar controller .Each tab bar item has a navigation controller and there is 开发者_开发知识库a log out button on first tab bar item.Now if i navigate into different naigation controllers and log out then all the navigation controllers remain in the same state for new user.I want all the navigation controleers to get to root when users logs out.
Try this:
for (UINavigationController *navController in myViewController.tabBarController.viewControllers) {
[navController popToRootViewControllerAnimated:NO];
}
i think your prob can be solved by writing a method for logging out and the method pops all the view controllers added to the root controller.when the user taps on the logout button all the view controllers should be popped and if needed call the action in all the three view controllers.
hope it would work..
jtbandes, your answer works really well, but what if I need to push the root view controller for only one tab? I don't want other tabs to be modifier, I just need to push the root view controller of one tab.
精彩评论