0

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.

4

2 回答 2

0
[[super.tabBarController.viewControllers objectAtIndex:2] tabBarItem].badgeValue = @"1";
于 2013-04-16T09:18:29.863 回答
0

没有看到你的代码很难说,但有两种可能性浮现在脑海中:

  1. 您正在尝试从不是主线程的线程设置徽章值。尝试将您的徽章值设置代码包装dispatch_async到主队列中:

    dispatch_async(dispatch_get_main_queue(), ^
    {
        // set badge number    
    });
    
  2. 您设置 badgeValue 的项目为零。尝试在添加徽章编号的行中添加断点或一些 NSLog 语句,并检查某些对象的值是否为 nil。

于 2013-04-16T09:24:35.717 回答