【发布时间】:2013-05-23 10:16:35
【问题描述】:
我有一个带有标签栏控制器的应用程序。这些视图之一是表格视图。有一种方法可以在标签栏中设置此视图的徽章。这有效......但只有当用户触摸此视图而不是在启动应用程序时才正确。所以我尝试在 appDelegate 中使用这个方法……但这不起作用。 我在视图中的方法:
@property (strong) NSMutableArray *cars;
//some code here
-(void)SelectBadge
{
int r = [_cars count];
if (r == 0) {
self.navigationController.tabBarItem.badgeValue = 0;
}
else {
self.navigationController.tabBarItem.badgeValue = [NSString stringWithFormat:@"%d", r];
}
[self.tableView reloadData];
}
我尝试将此方法放入我的 appDelegate 文件中:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
CarList *Instance = [[CarList alloc] init];
[Instance SelectBadge];
}
提前感谢您的所有回答。
【问题讨论】:
标签: ios tabbar appdelegate badge