1. 程式人生 > >[iOS] How to switch from one Tab bar to another via program

[iOS] How to switch from one Tab bar to another via program

選取中的 tab 的切換,原來只需要設定 index:

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;

解法2:

Set selectedViewController property of UITabBarController

:

self.myTabBarController.selectedViewController = myViewController;

Use as below

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

from: