How to display the tabs when click the back button from hided tab view controller

132 Views Asked by At

I created a tab bar controller and from one tab item I gave segue to the navigation view controller. And I create a some view controllers attached to navigation controller. So in one view controller I don't need a tabs so in that controller I wrote to hide the tab bar controller that is self.tabBarController?.tabBar.isHidden = true.

When I click the back button of navigation controller from hided tab view controller to previous controller, it doesn't show the tab bar items in previous controllers. But I needed tabs in all view controller except in one view controller. Why does it not show the tabs?

This is my story board :

enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

You can try this in the VC that's before the one you hide the tab in

 override func viewWillAppear(_ animated:Bool) {
    super.viewWillAppear(animated)
    self.tabBarController?.tabBar.isHidden = false
}
0
On

You can use hidesBottomBarWhenPushedin the view controller which you don't need tabs. Fits your situation.

let controller = ViewControllerTwo()
controller.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(controller, animated: true)

A little more explanation:

self.tabBarController?.tabBar.isHidden = true globally changed the self.tabBarController's property hideTabBar across its children controllers stack.