tags:

views:

221

answers:

1

I have a tabbar with 4 buttons on it. When the user presses the A button I want to call functionA. When the user presses the B button I want to call functionB and so on.

I have implemented the UITabBarDelegate.

I have this code and it fires as expected when any button on the tabbar is pressed.
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item

What I am looking for is a code snippet that illustrates how to detect which button was pressed inside the delegate presumably using item.

+1  A: 

Thanks to iwat's comment below I edited this to be simpler.

The following is a delegate call for the UITabBarController, rather than the UITabBar itself.

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {  
    tabBarController.selectedIndex;
}
ordord00
Why make it hard? You can use tabBarController.selectedIndex instead.
iwat
Good point. I forgot about that property...
ordord00