从另一个视图控制器显示导航栏时,我无法在视图控制器中看到导航栏
我尝试保留
self.navigationController?.navigationBar.isHidden = false
,并且还尝试将导航控制器保留到嵌入的视图控制器中。
控制器A:-
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController =
storyboard.instantiateViewController(withIdentifier:"Identifier") as! B
present(viewController, animated: true, completion: nil)
控制器B:-
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.isHidden = false
}
答案 0 :(得分:0)
如果您以编程方式进行操作,那么它将对您有所帮助:-
SWIFT 4
let vc = UIStoryboard.init(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "IKDetailVC") as? IKDetailVC
self.navigationController?.pushViewController(vc!, animated: true)
答案 1 :(得分:0)
尝试
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let ViewController =
storyboard.instantiateViewController(withIdentifier:"Identifier") as! B
let vc = UINavigationController(rootViewController: ViewController)
present(vc, animated: true, completion: nil)
答案 2 :(得分:0)
在第一个视图控制器viewWillAppear()中,添加以下内容:
override func viewWillAppear(animated: Bool) {
self.navigationController?.navigationBarHidden = true
}
在第二个中,添加以下内容:
override func viewWillAppear(animated: Bool) {
self.navigationController?.navigationBarHidden = false
}
override func viewDidDisappear(animated: Bool) {
self.navigationController?.navigationBarHidden = true
}
快乐编码