gpt4 book ai didi

ios - 打开另一个带有选项卡栏和导航栏的 Storyboard

转载 作者:行者123 更新时间:2023-11-29 05:40:18 24 4
gpt4 key购买 nike

我正在另一个 Storyboard中创建欢迎页面我还有一个跳过按钮,可以打开主 Storyboard

在主 Storyboard中,有一个 minTabbar,每个选项卡都有自己的导航栏

这是我在跳过按钮的操作中的代码

var window: UIWindow?
let mainStoryBoard = UIStoryboard(name: "Main", bundle: nil)

@IBAction func skipButton(_ sender: UIButton) {

let todoTabBar = mainStoryBoard.instantiateViewController(withIdentifier: "mainTabBar") as! UITabBarController
todoTabBar.selectedIndex = 1
let nvc = todoTabBar.selectedViewController as? UINavigationController
nvc?.popToRootViewController(animated: false)
}

但它不起作用,点击按钮后没有任何反应,你能帮我吗?非常感谢您

最佳答案

这个

let nvc = todoTabBar.selectedViewController as? UINavigationController
nvc?.popToRootViewController(animated: false)

使用当前未显示/呈现的 vc 进行播放,因此所有操作都将即时进行,请确保访问真实呈现的 1 或显示 todoTabBar(如果是这种情况)


如果您需要离开当前的 VC,请这样做

self.present(todoTabBar,animated:true,completion:nil)

如果您需要使 todoTabBar 成为唯一呈现的 1 个操作

(UIApplication.shared.delegate as! AppDelegate).window!.rootViewController = todoTabBar

关于ios - 打开另一个带有选项卡栏和导航栏的 Storyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56622030/

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