开发者

Method to load a tab bar item?

开发者 https://www.devze.com 2023-03-25 06:41 出处:网络
I have 2 tab bar items. The first tab have a navigation controller(3 views) within. Say I am on the 3rd vie开发者_Go百科w of the navigation controller, how do I load the 2nd tab.So you want to switch

I have 2 tab bar items. The first tab have a navigation controller(3 views) within.

Say I am on the 3rd vie开发者_Go百科w of the navigation controller, how do I load the 2nd tab.


So you want to switch from the first tab to the second tab. Well you first you need to acces the tabbarController. Most of the time you would have the tabbar controller in AppDelegete. Calling the delegate like this:

MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];

Then the just set the selectIndex:

[delegate.tabBarController setSelectedIndex:1];

or

[delegate.tabBarController setSelectedViewController:self.secondViewController];
0

精彩评论

暂无评论...
验证码 换一张
取 消