提问者:小点点

如何从故事板将UITabBarController设置为rootViewController


简短的问题:

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

长问题:

我不是swift专家,但我从一开始就设法使用XIBs创建了一个完整的应用程序。 现在我需要我的应用程序从故事板开始,作为从01/07/2020年1月发布更新到appstore的新要求,但我从来没有用它来构建我的视图。 修改我的应用程序让我的情节提要作为入口点很容易,但问题是我今天的初始视图是一个TabController,我不知道如何从最初的情节提要导航到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
}

共1个答案

匿名用户

检查它的值“Is initial View controller”。