Hari Narayanan Hari Narayanan - 8 months ago 44
Objective-C Question

How to set Tab bar item badgeValue in objective c?

Actually I have one custom

and I need to set badgeValue for separate
at initially that custom tabar loaded with that index path of the tab bar item.

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

I used above code for that
but it shows only when I click on the tab bar item.

and I have also tried the below code in
custom tabBarController
but it didn't working.

[[self.tabBarController.tabBar.items objectAtIndex:3] setBadgeValue:@"2"];

I need to display the badge value at initial.


If you want to set badge number when you show first tab of your tabbarcontroller then set

  [[self.tabBarController.tabBar.items objectAtIndex:3] setBadgeValue:@"2"];

in viewdidload of your first tab, means first viewcontroller of your tabbbarcontroller