i use presentModalViewController to show some controller.
A controller://it will show controller of B and receive a message ,when it receive the Message,i want to kown the B is it show or not?
-(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 controller://when B was show ,i do not want call recvPushMessage in A.
-(void)viewDidLoad{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recvPushMessage:) name:RECV_PUSH_MESSAGE_NOTIFY object:nil];
}
-(void)recvPushMessage{
//do something for B
}
Check if this is what you are looking for,
For version < iOS 5.0, you can use
self.modalViewController.Update:
For your second question, you can get the
topViewControllerof navigation controller and compare it with C. You can use something like[self.modalViewController topViewController]to check if it is C and then proceed.For eg:-