Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting badge value in UITabBarItem in UIViewController

I am adding UITabBarController to the window, and setting the viewControllers property of the UITabBarController to the array of ViewControllers. If i am setting the badge value inside the viewController then its working fine. self.tabBarItem.badgeValue = @"3";

But if i am setting the viewControllers property of the UITabBarController to the array of navigation controllers which is having view controller as the rootviewcontroller, then its not setting the badge value.

Any suggestions ??

Thanks

like image 631
Biranchi Avatar asked Jan 31 '11 11:01

Biranchi


2 Answers

Yes, i got the answer.

[[self navigationController] tabBarItem].badgeValue = @"3";
like image 154
Biranchi Avatar answered Oct 17 '22 17:10

Biranchi


Or this:

[[self.tabBarController.tabBar.items objectAtIndex:2] setBadgeValue:[NSString stringWithFormat:@"%d",[UIApplication sharedApplication].applicationIconBadgeNumber]];
like image 22
BabyPanda Avatar answered Oct 17 '22 18:10

BabyPanda