当新的推送通知到达时,我如何更新特定UITabBarItem的徽章?例如Instagram中的activity选项卡
应该使用以下代码:
[[[[[self tabBarController] tabBar] items]
objectAtIndex:tabIndex] setBadgeValue:badgeValueString];
NSString *badgeValue = [NSString stringWithFormat:@"%lu", (long)countUnreadMessages];
[[[[self viewControllers] objectAtIndex:indexOfTabbarItem] tabBarItem] setBadgeValue:([badgeValue isEqualToString:@"0"]) ? nil : badgeValue];