Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push segue from a view controller controlled by UITabBarController

Let's assume that a first view controller is connected with a UITabBarController and I want to make a push segue to the second view controller from this first view controller.

From my googling, it seems that a modal segue from a view controller connected with a UITabBarController hides the bottom tab bar, while a push segue doesn't. However, my push segue is also hiding my tab bar in the second view controller. I have overridden prepareForSegue method in the first view controller.

Below are images of my storybard and the simulator. Anyone has an idea why this is the case? Thank you in advance for your helps. The bottom right view controller seems to have bottom tab bar in the storyboard but the simulator doesn't show it TT

enter image description here

like image 773
CoderSpinoza Avatar asked Dec 21 '22 10:12

CoderSpinoza


1 Answers

Your trouble is because your tabViewController is embedded in the navigation stack that you initialise with your login screen.

you need to rearrange things so that each of your tab bar controller tabs opens to a new navigation stack.

What I suggest

  • your loginscreen should navigate to your tab bar controller with a modal/presenting segue, not a push segue. Remove the navController that encloses the loginscreen, you don't need it (well, even if you keep it, don't use a push segue, use a modal segue, and you won't then be referring back to that navController's viewController stack from inside your tab bar).

  • embed each of the first viewControllers in your tabViewCOntroller inside a separate navController.

Now you can push segue within your tabViewController's tabs.

like image 180
foundry Avatar answered Dec 28 '22 09:12

foundry