0

I have implemented Tab bar controller in IB. But when I write the following method in appdelegate.m, it is not called (I have put break point) when i tab.

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

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
HangarRash
  • 7,314
  • 5
  • 5
  • 32

1 Answers1

6

Wherever you create the UITabBarController, you need to set its delegate property to the custom UITabBarControllerDelegate object you've created.

If you've extended your application delegate to implement the methods of the UITabBarContollerDelegate protocol, and create the UITabBarController in the application delegate, then add the following after creating it:

tabBarVaribleName.delegate = self;
Ben S
  • 68,394
  • 30
  • 171
  • 212
  • Hello, i am have a similar problem. `I've posted my code here: http://stackoverflow.com/questions/10891182/iphone-how-to-implement-didselectviewcontroller/10891264`. My applicaiton is a tabbarapplication (that's what i selected when i started this xcode project). So does that mean i created my "UITabBarController in the application delegate" or did Xcode create it somewhere else? – John Jun 05 '12 at 17:40