开发者

Setting badge value in UITabBarItem in UIViewController

开发者 https://www.devze.com 2023-02-08 03:56 出处:网络
I am adding UITabBarController to the window, and setting the viewControllers property of the UITa开发者_C百科bBarController to the array of ViewControllers.

I am adding UITabBarController to the window, and setting the viewControllers property of the UITa开发者_C百科bBarController to the array of ViewControllers. If i am setting the badge value inside the viewController then its working fine. self.tabBarItem.badgeValue = @"3";

But if i am setting the viewControllers property of the UITabBarController to the array of navigation controllers which is having view controller as the rootviewcontroller, then its not setting the badge value.

Any suggestions ??

Thanks


Yes, i got the answer.

[[self navigationController] tabBarItem].badgeValue = @"3";


Or this:

[[self.tabBarController.tabBar.items objectAtIndex:2] setBadgeValue:[NSString stringWithFormat:@"%d",[UIApplication sharedApplication].applicationIconBadgeNumber]];
0

精彩评论

暂无评论...
验证码 换一张
取 消