The default behavior of a UITabBarController is to pop the contained UINavigationController to the root view controller when a particular tab is tapped a second time. I have a particular use case where I'm wanting this to not work automatically, and I'm having a hard time figuring out how to prevent this.
Has anyone run into this, and if so, what did you do? Do I need to subclass UINavigationController and override popToRootViewController or is there a simpler way?
this is what I did:
regards
This behavior is a little strange, but a handy shortcut in case of deep hierarchy!
You can implement following UITabBarControllerDelegate methods to disable this system wide shortcut:
Use the tabBarController:shouldSelectViewController: method of the UITabBarControllerDelegate protocol.
Don't forget to set the delegate of the tab bar controller to the object that actually implements this delegate method.
Update Swift 4.1
Hope it helps...
Thanks!!!
Here is the Swift 3 version: