I have 5 tabBarItem in my UITabBarController
One scenario, I have to open First index of UITabBarItem by clicking third UITabBarItem
My approach as in below:
extension FiveTabbarController: UITabBarControllerDelegate {
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
if item == (self.tabBar.items!)[2] {
tabBar.selectedItem = (self.tabBar.items!)[0] // ERROR
self.selectedIndex = 0 // NOT WORKING
}
}
}
Error: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Directly modifying a tab bar managed by a tab bar controller is not allowed.'
Kindly guide me how to achieve this.