【问题标题】:ios change the tabbaritem's badge in the AppDelegate [duplicate]ios在AppDelegate中更改tabbaritem的徽章[重复]
【发布时间】:2014-02-18 23:27:18
【问题描述】:

哦!我尝试在AppDelegate 中更改tabbarItem 的徽章;然后它确实有效,但tabarItem 没有显示!我的代码:

 UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    UITabBarController *tabBarController = (UITabBarController *)[storyBoard instantiateViewControllerWithIdentifier:@"MainIdentifier"];

    [[tabBarController.tabBar.items objectAtIndex:1] setBadgeValue:[NSString stringWithFormat:@"199"]];

(我也看到了网站How to set tabBarItem's badge from AppDelegate.m (tabBarView is not root View))

【问题讨论】:

    标签: badge


    【解决方案1】:

    您可以投票给原始答案here by Jim Rota

    访问标签栏控制器:"

    UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
    

    然后设置徽章

    [[tabController.viewControllers objectAtIndex:1] tabBarItem].badgeValue = @"New!";
    

    【讨论】:

      猜你喜欢
      • 2012-09-20
      • 2017-06-15
      • 2019-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-11
      相关资源
      最近更新 更多