如何在iphone的tabbar中设置badgevalue?

如何在iphone的tabbar中设置badgevalue?,iphone,objective-c,Iphone,Objective C,我正在使用以下代码设置当前选项卡栏中的badgevalue,但它在选项卡栏中不可见 self.navigationController.tabBarItem.badgeValue = @"1" 将badge值放入选项卡栏的正确方式是什么。这是我在选项卡项上访问badgeValue的方式: UITabBarItem * tabBarItem = (UITabBarItem *)[aTabBarController.tabBar.items objectAtIndex:1]; tabBarItem

我正在使用以下代码设置当前选项卡栏中的badgevalue,但它在选项卡栏中不可见

self.navigationController.tabBarItem.badgeValue = @"1"

将badge值放入选项卡栏的正确方式是什么。

这是我在选项卡项上访问badgeValue的方式:

UITabBarItem * tabBarItem = (UITabBarItem *)[aTabBarController.tabBar.items objectAtIndex:1];
tabBarItem.badgeValue = @"1";

你知道为什么self.navigationController.tabBarItem.badgeValue=@“1”不起作用了吗?我也有同样的问题,但不知道为什么。
但它是这样工作的:

[[[[self tabBarController] tabBar] items] objectAtIndex:0] setBadgeValue:@"AB"];