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

Hi you need to embed each view controller that is within the tab bar in a navigation controller of its own. So the flow is like so (HomeVC is embedded in a NavController of it’s own):

                                         / --> `NavController` --> `ViewController1`
                                         | --> `NavController` --> `ViewController2`
`HomeViewController`-->`TabBarController`|--> `NavController` --> `ViewController3`
                                         \--> `NavController` --> `ViewController4`
  1. Go to Editor –> Embed In –> Tab Bar Controller (or Navigation Controller)

How to embed correctly

To answer your questions:

Each tab of a tab bar controller interface is associated with a custom (different [sic]) view controller. When the user selects a specific tab, the tab bar controller displays the root view of the corresponding view controller, replacing any previous views.

So the Root View Controller of the tab must be adjoined to a Navigation Controller; a navigation view controller must be next inline in order for the View Controller to inherit a Navigation. A Tab Bar switches views to whatever is next inline.

This document will help outline more information about it. https://developer.apple.com/documentation/uikit/uitabbarcontroller

Leave a Comment