gpt4 book ai didi

ios - 以编程方式呈现后,NavigationController 在 Swift 中为 nil

转载 作者:行者123 更新时间:2023-11-28 10:40:12 25 4
gpt4 key购买 nike

我像这样以编程方式呈现 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?

最佳答案

尝试在 viewWillAppear() 中打印或使用 self.navigationController?.navigationBar。

我认为 navigationController 是可选的。

关于ios - 以编程方式呈现后,NavigationController 在 Swift 中为 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50890620/

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