通知未被识别

发布于 2024-08-28 06:58:29 字数 870 浏览 3 评论 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永远不会被调用?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杆小烟枪 2024-09-04 06:58:29

您可以尝试使用以下方式发布通知:

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

作为发件人采用 vc 实例(自身)而不是 nil。也许这可以解决你的问题。

Could you try posting your notification with:

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

As sender take the vc instance (self) instead of nil. Maybe that's solving your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文