0

AppDelegate.h *****

@interface AppDelegate : UIResponder <UIApplicationDelegate,UITabBarControllerDelegate,UITabBarDelegate>

AppDelegate.m *****

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    NSLog(@"%lu",(unsigned long)tabBarController.selectedIndex);
}

This method not work any idea ? I want to scroll top when click tab bar item Help please :)

Gökhan Çokkeçeci
  • 1,388
  • 3
  • 16
  • 37
  • Please clarify "not work"? It's not being called at all? If so, did you set the delegate correctly? See http://stackoverflow.com/questions/20536756/detect-when-a-tabbar-item-is-pressed-via-uitabbarcontroller-from-app-delegate – Christian Garbin Feb 22 '15 at 15:58

1 Answers1

1

You just have to add this line in the viewDidLoad method of your first viewController :

self.tabBarController.delegate = ((AppDelegate *)[UIApplication sharedApplication].delegate);
Aymen HARRATH
  • 474
  • 3
  • 15