uttam
uttam

Reputation: 1364

how to set the badgevalue in tabbar in iphone?

I am using the following code to set the badgevalue in current tab bar but its not visible in tab bar

self.navigationController.tabBarItem.badgeValue = @"1"

what is the correct way of putting the badge value in the tab bar.

Upvotes: 3

Views: 2181

Answers (2)

dsfdf
dsfdf

Reputation: 106

Did you figure out why this self.navigationController.tabBarItem.badgeValue = @"1" didn't work? I got the same problem but didn't know why.
But this way it works:

[[[[self tabBarController] tabBar] items] objectAtIndex:0] setBadgeValue:@"AB"];

Upvotes: 2

Tom Irving
Tom Irving

Reputation: 10069

This is how I access the badgeValue on a tabBarItem:

UITabBarItem * tabBarItem = (UITabBarItem *)[aTabBarController.tabBar.items objectAtIndex:1];
tabBarItem.badgeValue = @"1";

Upvotes: 3

Related Questions