How do I set the default tab for tab bar controller in swift
User Omkar responded above with the correct answer. I can successfully switch the first tab using the following viewDidAppear in ThirdViewController.swft
override func viewDidAppear(animated: Bool) {
self.tabBarController?.selectedIndex = 0
}
I followed @Paolo Sangregorio way The code to do it as follows
in appdelegate find applicationDidBecomeActive
function and add this lines
let tabBarController = self.window?.rootViewController as! UITabBarController
tabBarController.selectedIndex = 0