通过覆盖 TabbarViewController 中的 shouldSelect 方法推送视图控制器
Push View Controller by overriding shouldSelect method in TabbarViewController
我想在选择 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)
我想在选择 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)