-1

The documentation says that the didSelectViewController method of the UITabBarControllerDelegate is called when re-clicking on the selected item.

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITabBarControllerDelegate_Protocol/index.html#//apple_ref/occ/intfm/UITabBarControllerDelegate/tabBarController:didSelectViewController:

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 ?

jptsetung
  • 9,064
  • 3
  • 43
  • 55
  • What ? The document said that `In iOS v3.0 and later, the tab bar controller calls this method regardless of whether the selected view controller changed`. And your testing matched the document ! – Proton Jun 28 '16 at 12:21
  • "regardless of whether the selected view controller changed" means it's called only when the view controler changes ? – jptsetung Jun 28 '16 at 12:30
  • Sorry you, my mistake :( – Proton Jun 28 '16 at 12:37
  • I don't know if it's you, if so, don't forget to cancel the downvote on the question. Nobody will try to answer it if it's rated -1 I think. – jptsetung Jun 28 '16 at 12:58

1 Answers1

0

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);
}
jptsetung
  • 9,064
  • 3
  • 43
  • 55