Search code examples
swiftuinavigationcontrolleruitabbarcontroller

How to embed in a viewcontroller without tab bar when the parent is a tab bar viewcontroller?


My current hierarchy is:

  1. Tab bar controller
  2. Navigation controller
  3. A UIViewController
  4. Another UIViewController

It shows tab bars at the second UIViewController (so number 4 in the list). I want to remove that tab bar, but I want to keep the navigation at the top. This is because the first UIViewController (number 3 in the list) holds a tableview, and when a user clicks on a cell it goes to the second UIViewController and I want to keep a back button.

An example is when you open WhatsApp, you have a list of conversations (left side of image). When you click on a conversation, the tab bar buttons at the bottom are gone (right side of image). I can hide them in the second UIViewController, but it causes some glitches. I am sure there is a better solution.

enter image description here


Solution

  • In presented/pushed viewController's viewDidLoad, or in the storyboard, set the view controller's hidesBottomBarWhenPushed to true.