0

我正在尝试发布通知但没有成功!我可以毫无问题地使用键盘,但现在正在尝试自定义键盘,如下所示:

在我的根视图中,我有这个

。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 永远不会被调用?

4

1 回答 1

0

您能否尝试通过以下方式发布通知:

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

作为发件人,使用 vc 实例(self)而不是 nil。也许这正在解决你的问题。

于 2010-04-08T11:26:10.060 回答