I have a UITabBarController that has 5 different view controllers attached to it. Each one has there own specific tab such as Home, Settings, etc. How can i set a certain tab to be the default tab when launched?
Is there a specific reason why you can't move your chosen first tab to be presented to the left most slot?
self.tabBarController.selectedIndex = desiredIndex
or, if you're code is in a UITabBarConroller subclass, simply:
selectedIndex = desiredIndex
should work.
You could consider changing the tab in the app delegate's didFinishLaunchingWithOptions
(or whatever owns the tab bar controller) with code like this:
if let tabController = window?.rootViewController as? UITabBarController {
tabController.selectedIndex = 1
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.