我正在构建一个集成了 chap 的应用,但导航栏不会显示。
我正在使用这种方法从菜单导航到对话视图控制器(它嵌入在导航控制器中并包含一个 TableView):
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let _vc = storyboard.instantiateViewController(withIdentifier: "conversacionesVC") as! ConversationsViewController
_vc.modalPresentationStyle = .fullScreen
present(_vc, animated: true)
名为“显示导航栏”的属性已经被选中,但是当对话视图控制器出现时,它缺少导航栏。
答案 0 :(得分:0)
您可以使用 navigationController.pushViewController
方法或呈现 navigationController
而不是 viewController
,如下所示。
现在的 UINavigationController:
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。
答案 1 :(得分:0)
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)