1
votes

Problem with back button

I am having a problem with the back button not going to the previous view controller despite me using segues (via push). I think there is a problem since I saw this line on Apple's documentation saying

"An app that uses a tab bar controller can also use navigation controllers in one or more tabs. When combining these two types of view controller in the same user interface, the tab bar controller always acts as the wrapper for the navigation controllers."

But I want to be able to use a login screen which then moves onto a couple of screens before getting to a tab bar controller therefore not having the navigation bar wrapped in the tab bar controller. I know many popular apps use this, for example Instagram where you login then it shows the tab bar controller.

My current app layout is this;

Root navigation controller -> login -> meals (gif) -> tab controller (navigation controller for each tab (as per link) -> (My Rota/ My Meals/ Shopping List/ Item)

How to implement tab bar controller with navigation controller in right way

1
Why don't you present your tab bar controller modally after you finish with your login screens? See Creating a Tab Bar Interface here for apple's suggested arrangements. - beyowulf
Alternately present a navigation controller containing your login flow modally on top of your tab bar controller and dismiss it once the login process is complete. - Jonah
@beyowulf Thanks a lot, I didn't know about modal presenting. I just have one issue, if someone has logged in and then goes to settings and logs out (presented modally as well) then when they log back in, it will dismiss the viewController and go to the settings page (where they logged out) rather than the first tab. Could you think of any way to get around that? Thanks a lot, Jake - Jake Walker

1 Answers

3
votes

It looks like it is behaving as expected, the back button is for your root navigation controller and when you use the 'back' button it pops your tab bar controller. I actually expected you to see two navigation bars, your root one and the one in the My Meals tab, unless you hide one.

You could hide the root navigation bar when you push the tab bar, but you'll probably need a button in each tab's navigation bar which pops the tab bar from the root navigational controller.

Beyowulf's suggestion of presenting it as a modal is another option.