简体   繁体   English

如何从 Storyboard 将 UITabBarController 设置为 rootViewController

[英]How to set a UITabBarController as rootViewController from Storyboard

Short question:简短的问题:

How can I launch and make a UITabBarController be the rootViewController of my app after starting with a Storyboard?从 Storyboard 开始后,如何启动 UITabBarController 并将其设置为我的应用程序的 rootViewController?

Long question:长问题:

I'm not a swift expert, but I managed to create a complete app using XIBs from the beginning.我不是 swift 专家,但我从一开始就设法使用 XIB 创建了一个完整的应用程序。 Now I need my app to start with a Storyboard as a new requirement to post updates to the appstore from 01/07/2020, but I never used it to build my views.现在我需要我的应用程序以 Storyboard 作为从 2020 年 1 月 7 日起向应用商店发布更新的新要求,但我从未使用它来构建我的视图。 It was easy to modify my app to have my Storyboard as an entry point, but the problem is that my initial view today is a TabController, and I don't know how to navigate from my initial Storyboard to my TabController.修改我的应用程序以将我的 Storyboard 作为入口点很容易,但问题是我今天的初始视图是 TabController,我不知道如何从初始 Storyboard 导航到我的 TabController。

My AppDelegate today works something like this:我今天的 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()

}

All my attempts ended with a white screen after showing my Storyboard without showing my TabBar.在显示我的 Storyboard 而不显示我的 TabBar 后,我所有的尝试都以白屏结束。

One of these attempts was this:这些尝试之一是:

override func loadView() {
    super.loadView()
    // initiate tabController the same way I did in the AppDelegate
    UIApplication.shared.keyWindow?.rootViewController = tabController
}

在此处输入图像描述

Check the value "Is initial View Controller" for it.检查它的值“是初始视图控制器”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 UITabBarController 设置为 rootViewController - Set UITabBarController as rootViewController 如果UITabbarcontroller不是rootviewcontroller,如何从Appdelegate(无论何时有推送通知)为UIBarButtonItem设置徽章? - How to set badge for UIBarButtonItem from Appdelegate (whenever push notification comes) if UITabbarcontroller is not the rootviewcontroller? 从情节提要中设置时,UITabBarController过渡不起作用 - UITabBarController transition not working when set from storyboard 如何获得rootviewcontroller ios故事板 - how to get rootviewcontroller ios storyboard 如何使用 StoryBoard 在 UITabBarController 中设置选定的选项卡? - How do I set selected tab in UITabBarController using StoryBoard? 在Storyboard中设置的rootViewController未在App Launch上显示 - rootViewController set in Storyboard not showing on App Launch 如何设置rootViewController? - How to set rootViewController? 如何将tabBarController设置为rootViewController - How to set a tabBarController as rootViewController 如何将UIVIewController设置为RootViewController? - How to set UIVIewController to RootViewController? 来自storyboard的实例化NavigationController引用相同的RootViewController - Instantiated NavigationController from storyboard reference the same RootViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM