swiftuinavigationcontrolleruitabbarcontrollerpushviewcontroller

hidesBottomBarWhenPushed is not working when tabbarcontroller-viewcontroller's are embedded in navigation controller


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


Solution

  • 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