Navigation bar not showing iOS swift

前端 未结 7 1470
醉话见心
醉话见心 2021-02-18 13:24

I am having multiple view controller in my application. I want to hide navigationbar in my first view controller. So I use the following code to hide the navigation

相关标签:
7条回答
  • 2021-02-18 13:56

    Navigation Controller is a controller, which has stack of view controllers. So if you have something like this:

    NAV -> A -> (segue) B

    Even if you'll hide navigation bar you still should be able to make segues. Also can't you just unhide navigation bar in second (B) view controller in viewWillAppear? And in first the same way hide it on viewWillAppear.

    edit: Final solution to the problem: Use:

     let controller = storyboard.instantiateViewControllerWithIdentifier("HomeVC")
     self.navigationController!.pushViewController(controller) 
    

    instead of:

    let secondViewController = storyboard.instantiateViewControllerWithIdentifier("HomeVC")
    presentViewController(secondViewController, animated: false, completion: nil)
    

    Because pushViewController will add secondViewController to its stack. presentViewController was replacing your navigation controller that's why you couldn't see navigation bar.

    0 讨论(0)
提交回复
热议问题