vijju
vijju

Reputation: 462

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

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

Upvotes: 0

Views: 153

Answers (2)

black_pearl
black_pearl

Reputation: 2719

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.

Upvotes: 0

Shehata Gamal
Shehata Gamal

Reputation: 100549

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
}

Upvotes: 1

Related Questions