views:

963

answers:

2

Hi,

I have 4 tabs in my iphone application. When user will click a button in tab-1, I want to move/switch user to another tab suppose tab-2.

How to do that?

Thanks in advance. -Ruchir.

+3  A: 

You can use

[self.tabBarController setSelectedIndex:tabIndex];

where tabIndex is the index of the tab you want to switch to.

Jasarien
and how to check which tab is clicked? any delegate method?
Ruchir Shah
When switching tabs, the `- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController` delegate method will be called. All of this is available in the documentation. It took me less than a minute to find it and answer your question ;)
Jasarien
+1  A: 

Might also point out that if you are inside a view, you should use super instead of self.

Darkin
Just what i was looking for ! saved my life, thank you :)
grilix