Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I have 5 different tabs in my tabbar controller.

My intention is to be able to switch from one tab bar via code. For example I am currently in the 5th tab of the app and when I click on the 'done' button, the app should switch my view to the rootview controller belonging to the 1st tab.

Any advise on how I can do this?

like image 886
Zhen Avatar asked Jun 17 '11 06:06

Zhen


1 Answers

Set selectedViewController property of UITabBarController:

self.myTabBarController.selectedViewController = myViewController; 

Use as below

self.myTabBarController.selectedViewController      = [self.myTabBarController.viewControllers objectAtIndex:0]; 
like image 103
Jhaliya - Praveen Sharma Avatar answered Oct 04 '22 13:10

Jhaliya - Praveen Sharma