views:

746

answers:

4

hey i want to catch the event that controll the switch tabs on the UITabBarController

how can i accomplish it ?

thank you guys

A: 

Have a look at the following method in UITabBarControllerDelegate:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController

Tells the delegate that the user selected an item in the tab bar.

Vladimir
A: 

Is UITabBarControllerDelegate what you're looking for, particularly -tabBarController:didSelectViewController:?

Costique
+4  A: 

Implement UITabBarControllerDelegate e.g. in your app delegate's applicationDidFinishLaunching

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
    tabBarController.delegate = self;
    [window addSubview:tabBarController.view];
}

Then implement either:

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController;

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;

The first method is called before the view switch and gives you a chance to 'veto' the view switch by returning NO

The second method is called after the view switch has taken place

cidered
A: 

But how to detect perticular tab change event?

Gaurav aka sparsh