我使用 presentModalViewController 来显示一些控制器。
A控制器://它将显示B的控制器并接收消息,当它收到消息时,我想知道B是否显示?
-(void)viewDidLoad{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recvPushMessage:) name:RECV_PUSH_MESSAGE_NOTIFY object:nil];
}
-(void)buttonAction(id)sender{
B* b = [B alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:(UIViewController*)b];
[self presentModalViewController:navigationController animated:YES];
//release
}
-(void)recvPushMessage{
//i want to kown B is it show or not
if(b is showing){
//do something
}
else{
//do something for A
}
}
B控制器://当B显示时,我不想在A中调用recvPushMessage。
-(void)viewDidLoad{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recvPushMessage:) name:RECV_PUSH_MESSAGE_NOTIFY object:nil];
}
-(void)recvPushMessage{
//do something for B
}