[英]How to set a UITabBarController as rootViewController from Storyboard
简短的问题:
从 Storyboard 开始后,如何启动 UITabBarController 并将其设置为我的应用程序的 rootViewController?
长问题:
我不是 swift 专家,但我从一开始就设法使用 XIB 创建了一个完整的应用程序。 现在我需要我的应用程序以 Storyboard 作为从 2020 年 1 月 7 日起向应用商店发布更新的新要求,但我从未使用它来构建我的视图。 修改我的应用程序以将我的 Storyboard 作为入口点很容易,但问题是我今天的初始视图是 TabController,我不知道如何从初始 Storyboard 导航到我的 TabController。
我今天的 AppDelegate 是这样工作的:
var window: UIWindow?
func application(_application: UIApplication, didFinishLauchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
// initiate UINavigationControllers and UITabBarController here...
tabController.viewController = [nav1, nav2, nav3, nav4]
tabController.modalPresentationStyle = .fullScreen
self.window!.rootViewController = tabController
self.window!.makeKeyAndVisible()
}
在显示我的 Storyboard 而不显示我的 TabBar 后,我所有的尝试都以白屏结束。
这些尝试之一是:
override func loadView() {
super.loadView()
// initiate tabController the same way I did in the AppDelegate
UIApplication.shared.keyWindow?.rootViewController = tabController
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.