0
votes

My app ui heirarchy look like as shown. UItabbarcontroller -> navigation-controllers -> view-controllers.

enter image description here

The problem am facing is hidesBottomBarWhenPushed is not working when i try to push a new controller from 1st Vc on button click

if let newVc = UIStoryboard.homeSB.instantiateViewController(withIdentifier: NewViewController.identifier()) as? NewViewController{
    self.navigationController?.hidesBottomBarWhenPushed = true
    self.navigationController?.pushViewController(viewAllVc, animated: true)
}

The Tabbar is still showing in the NewVc

2

2 Answers

0
votes

To hide the tab bar in new VC you can call this in viewDidLoad():

self.tabBarController?.tabBar.isHidden = true

Also, you should call method hidesBottomBarWhenPushed from your VC, not from the navigation controller:

if let newVc = UIStoryboard.homeSB.instantiateViewController(withIdentifier: NewViewController.identifier()) as? NewViewController{
newVc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(viewAllVc, animated: true) 
}

Furthermore, you can make it on your new VC storyboard:

enter image description here

hidesBottomBarWhenPushed in developer.apple.com/documentation

0
votes

//use this method in the view controller where you want to hide tabBar

override var hidesBottomBarWhenPushed: Bool {
    get {
        return navigationController?.topViewController == self
    }
    set {
        super.hidesBottomBarWhenPushed = newValue
    }
}