選取中的 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: