IBAction 无法识别的选择器发送到实例

发布于 2024-12-08 13:55:40 字数 888 浏览 4 评论 0原文

我有一个简单的选项卡应用程序

我创建了一个 XIB 文件并将其分配给一个选项卡,当我触摸该选项卡时,它会准确地切换

添加了一个简单的 IBAction

我在 Tab1.h 中 -(IBAction)pleasebeep:(id)发件人;

在 Tab1.m

-(IBAction)pleasebeep:(id)sender 
{
    NSLog(@"honk");
}

界面生成器中,我创建了一个按钮并将其链接到所有者和操作“pleasebeep”,

它编译并启动。

当我单击按钮时,应用程序崩溃,并收到“-[UIViewController pleasebeep:]: 无法识别的选择器发送到实例 0x7b975c0 2011-10-06 04:32:25.648 FirstProject[8029:11903] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIViewController pleasebeep:]:无法识别的选择器发送到实例 0x7b975c0” * 首先抛出调用堆栈: (0x12de082 0x146fd0a 0x12dfd1d 0x1244f70 0x1244d52 0x12dfef9 0x37c542 0x37c4da 0x421576 0x421a3f 0x420cfe 0x3a1810 0x3a1a36 0x388234 0x37ba29 0x1ece10d 0x12b21f5 0x12170a2 0x121598a 0x1214e34 0x1214d4b 0x1ecc9dd 0x1eccaa2 0x379a1b 0x2749 0x26c5) 终止调用抛出异常当前语言:auto;目前objective-c”

知道在哪里寻找问题吗?

I have a simple tabbar app

I have created a XIB file and assigned it to a tab, and when I touch the tab, it accurately switches

I added a simple IBAction

in Tab1.h
-(IBAction)pleasebeep:(id)sender;

in Tab1.m

-(IBAction)pleasebeep:(id)sender 
{
    NSLog(@"honk");
}

In interface builder I have created a button and linked it to the Owner and action "pleasebeep"

It compiles and launches.

When I click the button, the app crashes and I get a "-[UIViewController pleasebeep:]: unrecognized selector sent to instance 0x7b975c0
2011-10-06 04:32:25.648 FirstProject[8029:11903] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController pleasebeep:]: unrecognized selector sent to instance 0x7b975c0'
*
First throw call stack:
(0x12de082 0x146fd0a 0x12dfd1d 0x1244f70 0x1244d52 0x12dfef9 0x37c542 0x37c4da 0x421576 0x421a3f 0x420cfe 0x3a1810 0x3a1a36 0x388234 0x37ba29 0x1ece10d 0x12b21f5 0x12170a2 0x121598a 0x1214e34 0x1214d4b 0x1ecc9dd 0x1eccaa2 0x379a1b 0x2749 0x26c5)
terminate called throwing an exceptionCurrent language: auto; currently objective-c"

Any idea where to hunt for the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

孤独难免 2024-12-15 13:55:40

您是否为文件所有者设置了正确的自定义类?也许它仍然设置为默认类“UIViewController”

Have you set the right Custom Class to the File's Owner? Maybe it's still set to the default class 'UIViewController'

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