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
Update Swift 4.1
Stop Double Tap for all tabs.
extension TabBarController: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
//for blocking double tap on all tabs.
return viewController != tabBarController.selectedViewController
}}
Stop Double Tap on only one specific tab. Here it's for 3rd Tab.
extension TabBarController: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
//for blocking double tap on 3rd tab only
let indexOfNewVC = tabBarController.viewControllers?.index(of: viewController)
return ((indexOfNewVC != 2) ||
(indexOfNewVC != tabBarController.selectedIndex))
}}
Hope it helps...
Thanks!!!