发送消息:
NSDictionary *dict=[[NSDictionary alloc]initWithObjectsAndKeys:@"num",[NSString stringWithFormat:@"%d",person.i_Msg], nil]; [[NSNotificationCenter defaultCenter] postNotificationName:@"hideTabBar" object:self userInfo:dict];
接收消息:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hideTabBar:) name:@"hideTabBar" object:nil];
-(void)hideTabBar:(id)sender { NSString *num=[[sender userInfo] objectForKey:@"num"]; _numOfmsg = _numOfmsg-[num intValue]; [self.tabBar showBadgeOnItemIndex:3 andNumber:_numOfmsg]; if (_numOfmsg==0) { [self.tabBar hideBadgeOnItemIndex:3]; } }
时间: 2024-10-28 09:19:06