How to exit from UITabBarController to UINavigationController on button click

大憨熊 提交于 2019-12-13 04:31:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!