gpt4 book ai didi

ios - 以编程方式将初始 View Controller 设置为选项卡 Controller swift 2

转载 作者:行者123 更新时间:2023-11-29 00:48:56 25 4
gpt4 key购买 nike

我的 iOS 应用程序上有一个选项卡 Controller ,我想首先检查一些条件并执行以下操作:

self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let mainStoryBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
if condition {
globalClass.token = u
let mvc: MainViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("mainView") as! MainViewController
self.window?.rootViewController = mvc

} else {
globalClass.token = ""
let mvc: LoginViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("loginView") as! LoginViewController
self.window?.rootViewController = mvc
}
self.window?.makeKeyAndVisible()

我的问题是,当我以编程方式将初始 View Controller 设置为加载选项卡 Controller 的第一个选项卡时,底部的选项卡菜单将不会加载。它只是加载 View Controller 而不是选项卡菜单。

MainViewController是选项卡 View Controller 的第一个选项卡

谢谢,

阿夫辛

最佳答案

试试这段代码。

让 tbc = mainStoryBoard.instantiateViewControllerWithIdentifier("tabbarStoryboardId") 作为! UItabBarController
self.window?.rootViewController = tbc

谢谢

关于ios - 以编程方式将初始 View Controller 设置为选项卡 Controller swift 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38333025/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com