通知未被识别
我正在尝试发布通知但没有成功!我能做到 键盘没问题,但现在我正在尝试定制一个 如下:
在我的根视图中,我有这个
.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永远不会被调用?
I am trying to post a notification without much success! I can do it
ok for the keyboard without issue but now am trying a custom one as
follows:
In my rootview I have this
.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];
But the allowEdits never gets called?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用以下方式发布通知:
作为发件人采用 vc 实例(自身)而不是 nil。也许这可以解决你的问题。
Could you try posting your notification with:
As sender take the vc instance (self) instead of nil. Maybe that's solving your problem.