如何从Storyboard设置UITabBarController作为rootViewController

问题描述 投票:0回答:1

简短问题:

从情节提要开始后,如何启动UITabBarController并使之成为我的应用程序的rootViewController?

长时间的问题:

我不是一个快速的专家,但是我从一开始就设法使用XIB创建了一个完整的应用程序。现在,我需要我的应用程序从情节提要开始,这是从01/07/2020起将更新发布到应用程序商店的一项新要求,但是我从未使用过它来构建视图。修改我的应用程序以使我的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()

}

[我的所有尝试都在显示情节提要而未显示TabBar后以白色屏幕结束。

这些尝试之一是:

override func loadView() {
    super.loadView()
    // initiate tabController the same way I did in the AppDelegate
    UIApplication.shared.keyWindow?.rootViewController = tabController
}
ios swift storyboard xib
1个回答
0
投票

enter image description here

为其检查值“是初始View Controller”。

© www.soinside.com 2019 - 2024. All rights reserved.