1

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

Community
  • 1
  • 1
Jake Walker
  • 305
  • 2
  • 9
  • Why don't you present your tab bar controller modally after you finish with your login screens? See *Creating a Tab Bar Interface* [here](https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/TabBarControllers.html#//apple_ref/doc/uid/TP40011313-CH3-SW1) for apple's suggested arrangements. – beyowulf Sep 08 '16 at 21:45
  • 2
    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 Sep 08 '16 at 22:37
  • @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 Sep 09 '16 at 12:38

1 Answers1

3

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.

JingJingTao
  • 1,760
  • 17
  • 28