简体   繁体   中英

Navigation bar won't show when navigating between viewControllers

I am building an app with a chap integrated but the navigation bar won't show.

I am using this method to navigate from the Menu to the Conversations View Controller (which is embedded in a Navigation Controller and contains a TableView):

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let _vc = storyboard.instantiateViewController(withIdentifier: "conversacionesVC") as! ConversationsViewController
_vc.modalPresentationStyle = .fullScreen
present(_vc, animated: true)
 

The property called "Shows Navigation Bar" is already checked but when the Conversations View Controller appears, it is missing the navigation bar.

You can use navigationController.pushViewController method or present a navigationController not a viewController like below.

Present UINavigationControlller:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let _vc = storyboard.instantiateViewController(withIdentifier: "yourNavigationController") as? UINavigationController
_vc.modalPresentationStyle = .fullScreen
self.present(_vc, animated: true)

Note: Make sure your navigationController rootViewController is your presented viewController.

let storyboard = UIStoryboard(name: "Main", bundle: nil)
guard let _vc = storyboard.instantiateViewController(withIdentifier: "yourNavigationController") as? ConversationsViewController else{return}

vc.modalPresentationStyle = .fullScreen
let navVc = UINavigationController.init(rootViewController: _vc)
self.present(navVc, animated: true)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM