gpt4 book ai didi

swift - 使用 Present 查看另一个 View Controller 时看不到导航栏

转载 作者:行者123 更新时间:2023-11-30 10:45:29 24 4
gpt4 key购买 nike

在从另一个 View Controller 呈现导航栏时,我无法在 View Controller 中看到导航栏

我尝试过保留

self.navigationController?.navigationBar.isHidden = false

还尝试将导航 Controller 保留到 View Controller (嵌入)。

Controller A:-

let storyboard = UIStoryboard(name: "Main", bundle: nil)

let viewController =
storyboard.instantiateViewController(withIdentifier:"Identifier") as! B

present(viewController, animated: true, completion: nil)

Controller B:-

override func viewWillAppear(_ animated: Bool) {           
super.viewWillAppear(animated)

self.navigationController?.navigationBar.isHidden = false

}

最佳答案

试试这个

let storyboard = UIStoryboard(name: "Main", bundle: nil)

let ViewController =
storyboard.instantiateViewController(withIdentifier:"Identifier") as! B

let vc = UINavigationController(rootViewController: ViewController)

present(vc, animated: true, completion: nil)

关于swift - 使用 Present 查看另一个 View Controller 时看不到导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55826940/

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