0

I am trying to set a badge value for a tab bar item embedded in a navigation controller from the tabBarController.m (tab bar controller --> navigation bar --> view controller), i used this code but it's not working:

[[self.tabBarController.tabBar.items objectAtIndex:0] setBadgeValue:eventCountStr];
yasser h
  • 599
  • 2
  • 9
  • 18

1 Answers1

0

Use this code to change the badge for the current tab

[[self navigationController] tabBarItem].badgeValue = @"BadgeValue";

If you need to change the value for another tab

[[super.tabBarController.viewControllers objectAtIndex:2] tabBarItem].badgeValue = @"1";

If you need to remove the badge use badgeValue as nil.

Himanth
  • 2,381
  • 3
  • 28
  • 41
  • I want to change the values from another tab but your second code which is similar to mine is not working. – yasser h Aug 18 '17 at 06:16