Using Swift 2 for iOS
How to set a default selected item in a tab bar of type UITabBar (Not UITabBarViewController), in viewDidLoad
i am creating my own tab view nib file, i need to find a way to allow
the tab bar to set a default item during viewDidLoad, i tried
these methods that I would often use for TabBarViewController but they are not found in the UITabBar
@IBOutlet weak var tabBar: UITabBar!
self.tabBar?.selectedIndex = 0
self.UITabBar?.selectedIndex = 0
tabBar.selectedIndex = tabBar.title("Tab1")
Are you sure your tabbar is allocated because self.tabbar?.selectedIndex won't work but neither will crash if your tabbar is nil.
Or have you tried something like this :
self.tabbar.selectedItem = self.tabbar.items!
did not test it but maybe it works.