Reputation: 395
If users touch any tab bar items, an alert is needed to present to confirm users' real intention.
Users can press OK to proceed the tab transitioning, or Cancel to stay on where they were.
However, methods like
tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController)
or
tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController)
seem to be impossible to intercept tab transitioning.
Any solutions to work around such issue?
Upvotes: 2
Views: 551
Reputation: 2001
Implement
UITabBarControllerDelegate
on your viewcontroller and there is a callback
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
So you can then deal with the changes.
Alternatively find out the current selected tab with
tabBarController.tabBar.selectedItem.tag
Upvotes: 3