gpt4 book ai didi

ios - 导航 Controller 从第二次转换开始显示

转载 作者:行者123 更新时间:2023-11-30 11:06:56 25 4
gpt4 key购买 nike

为什么导航栏不是立即显示,而是在屏幕上经过几次转换后才显示?

第一个屏幕

First Screen

第二个屏幕

Second Screen

第三屏幕

Third Screen

第四个屏幕

Fourth Screen

Storyboard之间的转换是通过代码完成的

let storyboard = UIStoryboard(name: "detail", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "Login") as! TwoViewController
self.present(vc, animated: true)

最佳答案

由于您正在呈现 View Controller 本身,因此它不会有任何导航 Controller 。如果您需要为 View Controller 提供导航 Controller ,请提供导航 Controller 而不是 View Controller 。

let storyboard = UIStoryboard(name: "detail", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "navigationControllerID") as! UINavigationController
self.present(vc, animated: true)

或者 - 以编程方式使用 NavController 包装 VC。

let storyboard = UIStoryboard(name: "detail", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "Login") as! TwoViewController
let nav = UINavigationController(rootViewController: vc)
self.present(nav, animated: true)

关于ios - 导航 Controller 从第二次转换开始显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52623900/

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