1

I Want to call my own method, i.e. myMethod() when same tab bar is selected which is already selected. I had tried to call didSelectMethod() but it is not called in my ViewController class. Please help me in this, Thank you Jagveer Rana

Rajesh
  • 10,318
  • 16
  • 44
  • 64
Jagveer Singh
  • 2,258
  • 19
  • 34

2 Answers2

1

It sounds like your ViewController class is not the delegate for your UITabBarController, otherwise tabBarController:didSelectViewController: would be called.

Make sure your delegate is linked up properly.

If that's not the problem, then there are a few other StackOverflow questions asking the same thing:
Tab bar, reload every time tab is pressed
Detect a re-tab on selected UITabbarItem

Community
  • 1
  • 1
siburb
  • 4,880
  • 1
  • 25
  • 34
1

Where you own your tabBarController instance there you set delegate

tabBarController.delegate= self; // It is must to set delegate

add the below delegate method

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    if ([viewController respondsToSelector:@selector(myMethod)]) {
        [viewController performSelector:@selector(myMethod)];
    }
}
Rajesh
  • 10,318
  • 16
  • 44
  • 64