0

In my app I use this code to update notify counter:

[[[[[self tabBarController] tabBar] items]
      objectAtIndex:3] setBadgeValue:unreadMsg];

Since the user can change the order of tabs (from "Other" menu managed from iOS), how can I find the new index to use for objectAtIndex?

[UPDATE]: - The Green Circle: is my TabBar Controller - The Red Circle: is the tab bar item that I want update - The Blue circle is where I want to check and update the badge value...

Anna I hope that is a little bit clear now.... And Thanks.

enter image description here

Blasco73
  • 2,980
  • 2
  • 24
  • 30
  • Is index 3 the current view controller? Try this: http://stackoverflow.com/questions/7820421/update-uitabbaritem-badgevalue-with-more-view –  Dec 12 '13 at 19:57
  • Loop through the tabBar.items array until you find the instance of the view controller class you are interested in then set that item's badgeValue. –  Dec 13 '13 at 16:49
  • Actually, you'll have to loop through the tabBarController.viewControllers array. Something like that. –  Dec 13 '13 at 16:55
  • Working. I have tagged my tab bar item from xCode with 999 and i used this code: for (UIViewController *vc in self.tabBarController.viewControllers) { if (vc.tabBarItem.tag == 999) { vc.tabBarItem.badgeValue = unread; } } Thanks so much Anna if you were here I'd pay a drink! :D – Blasco73 Dec 13 '13 at 17:34

0 Answers0