【发布时间】:2020-09-29 15:44:51
【问题描述】:
小问题:
从 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()
}
在没有显示我的 TabBar 的情况下显示我的 Storyboard 后,我的所有尝试都以白屏结束。
其中一个尝试是这样的:
override func loadView() {
super.loadView()
// initiate tabController the same way I did in the AppDelegate
UIApplication.shared.keyWindow?.rootViewController = tabController
}
【问题讨论】:
标签: ios swift storyboard xib