[[super.tabBarController.viewControllers objectAtIndex:2] tabBarItem].badgeValue = @"1";
Adding badge number in UItabbarView Controller in runtme
-
04-04-2022 - |
Frage
I am trying to add badge number in UITabBarController
and it is working . But i started NSTimer . when timer completed . it calls webservice and in return i get badge number .
but when i set badge number to UITabBarController
in this senario . it is no more working.
Lösung
Andere Tipps
It's hard to tell without seeing your code, but two possibilities spring to mind:
You're trying to set the badge value from a thread that is not the main thread. Try wrapping your badge value setting code in a
dispatch_async
to the main queue:dispatch_async(dispatch_get_main_queue(), ^ { // set badge number });
The item that you're setting the badgeValue on is nil. Try adding a breakpoint or some NSLog statements to the line where you add the badge number, and check the value of some of the objects isn't nil.