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.

War es hilfreich?

Lösung

[[super.tabBarController.viewControllers objectAtIndex:2] tabBarItem].badgeValue = @"1";

Andere Tipps

It's hard to tell without seeing your code, but two possibilities spring to mind:

  1. 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    
    });
    
  2. 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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top