gpt4 book ai didi

ios - 通过覆盖 TabbarViewController 中的 shouldSelect 方法推送 View Controller

转载 作者:行者123 更新时间:2023-11-28 05:35:55 45 4
gpt4 key购买 nike

我想在选择 TabBar 中的项目时推送 ViewController 我已经编写了以下代码,但它不起作用

func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
if let ind = tabBarController.viewControllers!.index(of:viewController) , bottomBarTabsArray[ind].viewType == BottomBarInfo.VIEWTYPE_ASSISTANT { //
let tabVC = AppStrings.appStoryBoard.instantiateViewController(withIdentifier: "assitantViewControllerID") as! AssitantViewController
self.selectedViewController?.navigationController?.pushViewController(tabVC, animated: true)
return false
}
return true
}

如何在选择标签栏项目时推送 ViewController 而不是切换到 ViewController

最佳答案

替换

self.selectedViewController?.navigationController?.pushViewController(tabVC, animated: true)

(self.selectedViewController as! UINavigationController ).pushViewController(tabVC, animated: true)

关于ios - 通过覆盖 TabbarViewController 中的 shouldSelect 方法推送 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58643192/

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