Objective C: How to switch from one Tab bar to another via program Objective C: How to switch from one Tab bar to another via program ios ios

Objective C: How to switch from one Tab bar to another via program


Set selectedViewController property of UITabBarController:

self.myTabBarController.selectedViewController = myViewController;

Use as below

self.myTabBarController.selectedViewController     = [self.myTabBarController.viewControllers objectAtIndex:0];


Heres a simpler answer (if you know the index of the Tab Bar item is not in the "more" view controllers):just get a reference of the tabController and set the "selectedIndex" property

self.tabBarController.selectedIndex = 0;

Reference: https://developer.apple.com/library/ios/documentation/uikit/reference/UITabBarController_Class/Reference/Reference.html#jumpTo_6


matomo