我试图隐藏单个视图控制器的导航控制器没有运气,导航栏隐藏第一个vc,但它没有显示第二个vc.
这是我在第一个vc中使用的代码:
override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) // Hide the Navigation Bar self.navigationController?.setNavigationBarHidden(true,animated: animated) } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) // Show the Navigation Bar self.navigationController?.setNavigationBarHidden(false,animated: animated) }
swift 4有什么变化?该代码在swift 3中有效…
解决方法
使用代码: – Swift 4
override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(true) // Show the Navigation Bar self.navigationController?.setNavigationBarHidden(true,animated: true) } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(true) // Hide the Navigation Bar self.navigationController?.setNavigationBarHidden(false,animated: false) }
我认为你在动画中做错了:是的