【发布时间】:2020-02-09 12:57:19
【问题描述】:
我刚刚更新到 iOS 13/Xcode 11,我正在尝试将我的 UIViewController 嵌入到 UINavigationController 中,就像我过去所做的那样。 ViewController 已显示,但我的 NavigationController 未显示。下面是我在 AppDelegate 中的 didFinishLaunchingWithOptions 方法中的内容。
window = UIWindow()
let vc = ViewController()
let navController : UINavigationController = UINavigationController(rootViewController: vc)
navController.navigationBar.titleTextAttributes = [.foregroundColor : UIColor.black]
window?.rootViewController = navController
window?.makeKeyAndVisible()
编辑: 我发现了我的错误,我试图以编程方式创建 VC,但我将情节提要作为“初始视图控制器”。即使我清除了项目常规设置中的“主界面”字段,这也完全忽略了我在 appdelegate 中的代码。
我还想指出,我的代码不应该在 appdelegate 中,而是应该在 SceneDelegate 中。更多信息在这里:https://medium.com/@ZkHaider/apples-new-uiscene-api-a-programmatic-approach-52d05e382cf2
【问题讨论】:
-
您是否尝试为导航栏设置标题?
标签: ios swift xcode uinavigationcontroller ios13