Gavin
Gavin

Reputation: 2824

Method to load a tab bar item?

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

Say I am on the 3rd view of the navigation controller, how do I load the 2nd tab.

Upvotes: 0

Views: 176

Answers (1)

rckoenes
rckoenes

Reputation: 69469

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];

Upvotes: 1

Related Questions