I'm looking to disable the functionality of pressing my tab bar and returning to the root view in the navigation hierarchy whilst also keeping this functionality for a button in my navigation bar.
So the only way I want the user to go back to the root view is by pressing the button in the navigation bar and not by tapping the tab bar button.
I've had a look around and tried several solutions but none seem to work as they disable the functionality for both the nav bar button and the tab bar button but not just the tab bar button.
Thanks!
A possibility would be to create a subclass of UITabBarController
and to implement the UITabBarControllerDelegate
protocol.
Then you could implement
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
and return NO
, when the particular viewController is selected again.
A way to do this is is to save the recently selected item and to compare it with the currently selected one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With