我正在构建一个集成了chap的应用程序,但导航栏不会显示。
我使用这个方法从菜单导航到对话视图控制器(它嵌入在导航控制器中,并包含一个TableView):
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let _vc = storyboard.instantiateViewController(withIdentifier: "conversacionesVC") as! ConversationsViewController
_vc.modalPresentationStyle = .fullScreen
present(_vc, animated: true)
属性"显示导航栏"已经被选中,但是当对话视图控制器出现时,它缺少导航栏。
您可以使用navigationController.pushViewController
方法,或者像下面这样呈现navigationController
而不是viewController
。
现在UINavigationControlller:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let _vc = storyboard.instantiateViewController(withIdentifier: "yourNavigationController") as? UINavigationController
_vc.modalPresentationStyle = .fullScreen
self.present(_vc, animated: true)
注意:确保你的navigationController rootViewController是你呈现的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)