我想知道如何从一个标签栏切换到另一个标签栏。 这是我的故事板I have two tab bars in story board But the problem is that I want to switch from My TabBar to MainTabBar
这是我的代码
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let MainTabBarController = storyBoard.instantiateViewController(withIdentifier: "MainTabBarController") as! MainTabBarController
self.present(MainTabBarController , animated: true, completion: nil)
答案 0 :(得分:0)
至少这两个标签栏控制器之间必定存在某种关系。 你可以:
答案 1 :(得分:0)
您需要更改let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewController(withIdentifier: "tabBarcontroller") as! UITabBarController
UIApplication.shared.keyWindow?.rootViewController = viewController
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewController(withIdentifier: "tabBarcontroller") as! UITabBarController
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window?.rootViewController = viewController
如果以上操作不起作用,请尝试:
{{1}}