The documentation says that the didSelectViewController method of the UITabBarControllerDelegate is called when re-clicking on the selected item.
In iOS v3.0 and later, the tab bar controller calls this method regardless of whether the selected view controller changed. In addition, it is called only in response to user taps in the tab bar and is not called when your code changes the tab bar contents programmatically.
But according to my tests, it's not (testing on iOS9), the method is only called when the active view controller changed. So am I doing something wrong ? Is there a way to detect a tap on the active tab bar item ?
OK, the reason the method didSelectViewController
was not called when it was the same as the selected view controller, was that I had this other delegate method implemented like this :
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
return (viewController != tabBarController.selectedViewController);
}