我以编程方式呈现UINavigationController:
let homeViewController = HomeViewController.loadFromNibNamed(nibNamed: "HomeViewController")
let homeNavigationViewController = UINavigationController(rootViewController: homeViewController!)
self.present(homeNavigationViewController, animated: true, completion: nil)
但是在HomeViewController中有一个self.navigationController!.navigationBar
的调用,其中navigationController是nil?
答案 0 :(得分:3)
尝试在viewWillAppear()中打印或使用self.navigationController?.navigationBar。
我认为navigationController是可选的。