I am trying to change tab bar in didFinishLaunchingWithOptions method programmatically, but it won't work, any idea?
I have tried:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if let tabBarController = self.window!.rootViewController as? UITabBarController {
tabBarController.selectedIndex = 0
}
return true
}
Thanks,
are you sure that your root view controller is UITabBarController? because it would seem that you do not enter the if-let. It's possibile that you've a navigation controller that contains your tab viewcontroller?