通知未得到承认

时间:2010-04-08 11:02:21

标签: iphone nsnotification nsnotificationcenter

我试图发布通知但没有太大成功!我能做到 确定键盘没有问题,但现在我正在尝试自定义的键盘 如下:

在我的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永远不会被调用吗?

1 个答案:

答案 0 :(得分:0)

您可以尝试使用以下网址发布通知:

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

由于发件人采用vc实例(self)而不是nil。也许这正在解决你的问题。