2
我使用presentModalViewController來顯示一些控制器。IOS使用presentModalViewController來顯示一些控制器
控制器://它將顯示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是表演,我不想叫recvPushMessage在A.
-(void)viewDidLoad{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recvPushMessage:) name:RECV_PUSH_MESSAGE_NOTIFY object:nil];
}
-(void)recvPushMessage{
//do something for B
}
presentedViewController必須是IOS5.0,如何約4.3 – zt9788
你可能在該版本使用'self.modalViewController'。 – iDev
讓我試試看,如果B推一些像「C」的控制器,並且C也收到這個消息,我怎麼可以把presentViewController當作C中的A @ – zt9788