You want to remove a badge from the current tab, or the one touched?
The right place to do this, either way, is in your tab bar controller delegate, in:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;
Note that this function gets called whenever the user taps on a tab bar button, regardless of whether the new view controller shown is different from the old one, so you'll want to track your current visible view controller. This is where you'll update that, too:
- (void)tabBarController:(UITabBarController *)tabBarController
didSelectViewController:(UIViewController *)viewController {
if(viewController != self.currentTabVC) {
// if you want to remove the badge from the current tab
self.currentTabVC.tabBarItem.badgeValue = nil;
// or from the new tab
viewController.tabBarItem.badgeValue = nil;
// update our tab-tracking
self.currentTabVC = viewController;
}
}