At app launch, I have UITabBarController as the root view controller. For this tab bar, I have total 7 ViewControllers. Inside AppDelegate.swift
in method application(application:didFinishLaunchingWithOptions:)
, if I do following, it works properly:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
self.tabBarController = self.window?.rootViewController as! UITabBarController
self.tabBarController.selectedIndex = 2
return true
}
This works perfectly and the third item in the tab bar is selected when the application is launched.
But, when I want to select any item which has gone under the more navigation controller (which means any index beyond 3), the self.tabBarController.selectedIndex = 5
simply does not work. The mentioned statement does work at any part after the app launch is complete, i.e., if I do self.tabBarController.selectedIndex = 5
inside the viewDidAppear
of first ViewController, it works; but it doesn't work at the time of app launch,i.e., in application(application:didFinishLaunchingWithOptions:)
. The tab bar selected item remains to default after the launch happens. What is the way I can change the selected index beyond 3 (which goes under moreNavigationController
) at the app launch?