2010-04-08 111 views
0

我想发布通知没有太多成功!我能做到这一点 确定为键盘没有问题,但现在我想一个自定义的 如下:通知未被识别

在我rootview我有这个

.H

-(void) allowEdits:(NSNotification *)notification; 

.M

//this section is run in method to present the passcode entry form 


[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(allowEdits:) name: @"PasscodeOK" object:nil]; 

PasscodeEntryViewController *vc = [[PasscodeEntryViewController alloc] 
init]; 

[self presentModalViewController: vc animated:YES]; 

[vc release]; 


// and this is the response to the notification 

-(void) allowEdits:(NSNotification *)notification { 

    NSLog(@"notification fired"); 
} 


// in the vc instance I have this to notify passcode was ok 

[[NSNotificationCenter defaultCenter] 
postNotificationName:@"PasscodeOK" object:nil]; 

[self dismissView]; 

但allowEdits永远不会被调用?

回答

0

你能尝试发布您的通知:

[[NSNotificationCenter defaultCenter] postNotificationName:@"PasscodeOK" object:self]; 

发件人采取VC实例(个体经营),而不是零。也许这是解决你的问题。

+0

嗨,是啊试过,但没有喜悦!问题是要调用的方法在父级中,并且通知已发布到子级中。从我可以看到的父母addObserver被忽略!这让我疯狂! 我只是不明白为什么它不会工作! – user7865437 2010-04-08 12:08:52

+0

好歹徒!这一次我发现它!当我在几周前实施通知时,我在viewDidDisappear方法中包含了一个调用来移除观察者!所以我刚添加它......它被删除了! DOH! – user7865437 2010-04-08 12:34:27