问题
I have a MainMenu which navigates me to a TabBarController with 4 views (4 Tabs) in it.
Now I've a button in the 4th view of the TabBarController which OnClick should take me to the MainMenu.
Problem is when I pushViewController (MainMenu) I'm not able to dismiss the TabBarController and also NavigationBar is not visible on the MainMenu!!
Can someone please suggest me how to solve this, Thanks in advance.
回答1:
Do not use this :
[self.navigationController pushViewController:mainMenuViewController animated:YES];
Try using this:
[self.navigationController popViewController Animated:YES];
Take the reference of your same MainMenu and then push to that view controller
回答2:
[self.parentViewController.navigationController popViewController animated:YES];
UITabBarController is a container controller and you're adding viewControllers into it like so:
NavController || TabBarController || DisplayingViewController
since displayingViewController doesn't have a navigationController associated with it but the TabBarController does, you need to call for its parentViewController.
来源:https://stackoverflow.com/questions/18332647/how-to-exit-from-uitabbarcontroller-to-uinavigationcontroller-on-button-click