iphone code - change the tabBar badge value from the viewController's

Viewed 24370

I have a UITabBarController,

How can I create/update the badge value of the tabBar item from my viewController ?

The tabBar item's created in the ib.

I connected the tabBar item to the controller using an IBOutlet UITabBar *tabBar.

thanks.

4 Answers

If your viewcontroller already has a tab bar controller associate with it, you can just drill down to the tab bar item and set its badge, like this:

[[[[[self tabBarController] tabBar] items] 
                   objectAtIndex:tabIndex] setBadgeValue:badgeValueString];

where tabIndex is the index of the tab item you want to set and badgeValueString is the string value you want to set on the tab.

Related