我试图隐藏一个没有运气的单 View Controller 的导航 Controller ,第一个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)
}

快速4发生了什么变化?该代码 swift 运行了3 ...

最佳答案

使用代码:- Swift 5

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(true)
// Hide the Navigation Bar
        self.navigationController?.setNavigationBarHidden(true, animated: true)
    }

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(true)
// Show the Navigation Bar
        self.navigationController?.setNavigationBarHidden(false, animated: false)
    }
我认为您在animated: true中做错了

10-08 06:09
查看更多