I would like to assign an action if the user attempts to select a currently selected tab.
For example, if tab 1 is selected and the user tries to select tab 1 again, I want to make my app do something.
Are there any UITabBarController methods that will intercept this attempt?
I've looked through UITabBar
, UITabBarController
, and UITabBarItem
APIs and can't find anything obvious.
答案 0 :(得分:5)
You have to set a UITabBarControllerDelegate
. Specifically the
- tabBarController:shouldSelectViewController:
method where you can simply check self.selectedViewController
against the view controller passed in. If they are the same, the selected is being selected again.