0
votes

I'm sure this has a simple answer, but I've searched everywhere and cannot find an answer. There always seems to be some small adjustment that makes it not applicable to my scenario.

I have an app whose Initial View Controller is set to a Tab Bar Controller (far left side in image below). There are many Navigation Controllers that are all segued (Relationship Segue => view controller) from the Tab Bar Controller. Each Navigation Controller is connected to an UIViewController.

Tab/Nav Controller Setup

Everything works as expected as I am segueing between one view controller and the next (i.e. using UIButtons and TableViewCells etc.) However, wherever I am navigating through the app, and I choose one of the Tab Bar Items it properly segues to the correct view controller however it does not list the last view controller's title (or 'Back') inside the Navigation Controller.

Nav Bar should say 'Home'

I'm guessing that it has to do with the initial view controller of the app being set as the root view controller, but I can't figure out how to make the last view controller's name appear in the Nav Bar. I've tried adding a separate Navigation Controller as the initial, but I can't connect the Tab Bar without an extra UIViewController which doesn't seem to function properly.

Any help would greatly be appreciated.

I should also mention that there are a couple of the UIViewControllers inside the app that are entirely made up of code and not in the storyboard.

1

1 Answers

0
votes

This is not how navigation controller and tab bar controller work. Tab bar controller is your root view controller, but it actually has nothing to do with the problem.

The best analogy here would be the web browser with multiple tabs opened. If you are on page A in first tab adn then switch to another tab you can't just press back to be on the on page A again. You'd have to return the the first tab for it because tabs are independent from each other.

Navigation controllers are there mainly to maintain user's view controllers navigation stack - if he taps a button to open another view controller (via push method of navigation controller), that view controller is put on the top of the navigation stack. Then you can remove the controller at the top of the stack by pressing "Back". If you switch tabs you see a new navigation controller and therefore a new stack.