Disable action - user taps on tabbar item to go to root view controller

后端 未结 1 650
情话喂你
情话喂你 2020-12-16 13:10

I want to disable the default action when user taps the tabbar item.

For example, i have a tabbar with Tab1, Tab2 and Tab3. In Tab1, user can navigate from View1 to

相关标签:
1条回答
  • 2020-12-16 14:03

    if you look at the UITabBarController delegate there is a method:

    - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
    

    If you implement this in your class, you can check if the UIViewController is the already displayed one and then return NO, which will stop this from happening.

    I had the same problem with a ABPeoplePicker object embedded in a UITabBarController, in that pressing the 'Contacts' tab a second time which was already displayed would make the ABPeoplePicker control show the 'Groups'

    0 讨论(0)
提交回复
热议问题