didSelectViewController 在活动标签栏项目上重新 clicking/tapping 时的行为
didSelectViewController behaviour when re clicking/tapping on the active tab bar item
文档说,当重新点击选中的项目时,会调用 UITabBarControllerDelegate 的 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.
但根据我的测试,它不是(在 iOS9 上测试),该方法仅在活动视图控制器更改时调用。那我做错了什么吗?有没有办法检测对活动标签栏项目的点击?
好的,当方法 didSelectViewController
与选定的视图控制器相同时,方法 didSelectViewController
没有被调用的原因是我有另一个这样实现的委托方法:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
return (viewController != tabBarController.selectedViewController);
}
文档说,当重新点击选中的项目时,会调用 UITabBarControllerDelegate 的 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.
但根据我的测试,它不是(在 iOS9 上测试),该方法仅在活动视图控制器更改时调用。那我做错了什么吗?有没有办法检测对活动标签栏项目的点击?
好的,当方法 didSelectViewController
与选定的视图控制器相同时,方法 didSelectViewController
没有被调用的原因是我有另一个这样实现的委托方法:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
return (viewController != tabBarController.selectedViewController);
}