gpt4 book ai didi

ios - 隐藏 View Controller 的导航栏

转载 作者:IT王子 更新时间:2023-10-29 05:28:37 24 4
gpt4 key购买 nike

我曾尝试隐藏单个 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)
}

swift 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 中犯了错误

关于ios - 隐藏 View Controller 的导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47150880/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com