我有一个功能可以将我导航到我想要的任何 View :
func move(identifier: String , viewController : UIViewController) {
let mstoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc: UIViewController = mstoryboard.instantiateViewController(withIdentifier: identifier)
viewController.present(vc, animated: true, completion: nil)
}
如何将它转换为导航到我想要的任何 tabBar 项目? 或者我可以使用什么来导航到我想要的任何 tabBar 项目?
提前致谢
编辑:
最佳答案
因为 UITabBarController
是您的应用程序的 rootViewController
,假设您知道要切换到此选项卡的索引即可。
let tabBarController = UIApplication.shared.keyWindow?.rootViewController as! UITabBarController
tabBarController.selectedIndex = tabIndex
self.presentingViewController!.presentingViewController!.dismiss(animated: true, completion: {})
关于ios - 导航到特定的 TabBar 项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40202390/