Setting badge value in UITabBarItem in UIViewController

 ̄綄美尐妖づ 提交于 2019-11-27 02:50:58

问题


I am adding UITabBarController to the window, and setting the viewControllers property of the UITabBarController 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


回答1:


Yes, i got the answer.

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



回答2:


Or this:

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


来源:https://stackoverflow.com/questions/4850540/setting-badge-value-in-uitabbaritem-in-uiviewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!