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

Posted in :

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

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


解法2:

Set selectedViewController property of UITabBarController:

self.myTabBarController.selectedViewController = myViewController;

Use as below

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

from:

http://stackoverflow.com/questions/6382139/objective-c-how-to-switch-from-one-tab-bar-to-another-via-program

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *