Search code examples
iosswiftuitableviewuinavigationcontroller

Navigation bar not to be seen when UITableViewController is pushed onto the navigation stack


Code in the view controller which is currently on a navigation controller stack. Now I want to push a UITableViewContoller onto the navigation stack. I'm using the following code:

let destinationVC = self.storyboard?.instantiateViewController(withIdentifier: "formTableVC") as! FormTableViewController

self.navigationController?.pushViewController(destinationVC, animated: true)

The UITableViewContoller shows up but the navigation bar is not shown. How to solve this issue? I want the design which has been carried forward to all the previous view controllers to be shown in the UITableViewContoller's navigation bar as well. Any help would be greatly appreciated. thank you.


Solution

  • Add the following code to viewDidLoad function of UITableViewContoller(FormTableViewController) Class

    self.navigationController?.setNavigationBarHidden(false, animated: false)