문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top