How can I switch to some tab in UITabBarController
using StoryBoard? I have tried the code below but without success (the tab is not selected):
Here is what I do (Swift 5.x):
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if let tabBarController = self.window?.rootViewController as? UITabBarController {
if let viewControllers: [UIViewController] = tabBarController.viewControllers {
tabBarController.selectedIndex = viewControllers.count-1
}
}
return true
}