无法识别的选择器发送到实例 (iOS)
可能的重复:
无法识别的选择器发送到实例
好吧...像其他许多人一样,我得到了一个“无法识别的选择器发送到实例”错误...
当我按下按钮时会出现问题,例如在这种情况下:
-(IBAction)gotoTone:(id)sender
{
if(self.tone == nil)
{
Tone *toneMain = [[Tone alloc]
initWithNibName:@"Tone" bundle:[NSBundle mainBundle]];
self.tone = toneMain;
[toneMain release];
}
[self.navigationController pushViewController:tone animated:YES];
}
错误是:由于未捕获的异常而终止应用程序'NSInvalidArgumentException',原因:'-[Tone gotoTone:]: 无法识别的选择器发送到实例 0x531caa0'
在我插入新视图作为呈现给用户的第一个视图后,错误开始发生...另外,我使用导航栏和起初我忘记进入 MainWindow.xib 并将导航控制器更改为新视图,但现在已修复。
你可以看到我的整个代码:
文件所在的.h:http://snipt.org/xnoO 文件所在的 .m: http://snipt.org/xnoM
不要介意所有注释掉的行,直到我解决这个问题...
我尝试通过阅读“无法识别的选择器发送到实例”的其他案例来找到解决方案,但我想我只是没有看到解决方案。我已经检查了我的 IB-connects,我已经清理了项目等等......
任何帮助将不胜感激
Possible Duplicate:
unrecognized selector sent to instance
Well... like so many others, I have gotten a "unrecognized selector sent to instance" error...
The problem occurs when I press a button, e.g. in this case:
-(IBAction)gotoTone:(id)sender
{
if(self.tone == nil)
{
Tone *toneMain = [[Tone alloc]
initWithNibName:@"Tone" bundle:[NSBundle mainBundle]];
self.tone = toneMain;
[toneMain release];
}
[self.navigationController pushViewController:tone animated:YES];
}
The error is: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Tone gotoTone:]: unrecognized selector sent to instance 0x531caa0'
The error started occurring after I inserted a new view as the first view presented to the user... Also, I use a navigation bar and at first I had forgotten to go into MainWindow.xib and change the Navigation Controller to the new view, but that is fixed now.
You can see my entire code her:
The .h in which the file occurs: http://snipt.org/xnoO
The .m in which the file occurs: http://snipt.org/xnoM
Don't mind all the out-commented lines, that's just until I get this fixed...
I've tried finding a solution to this by reading other cases of "unrecognized selector sent to instance", but I guess I'm just not seeing the solution. I've checked my IB-connects, I've cleaned the project and such...
Any help would be greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了这个问题,只需将 Button 重新连接到之前修改名称的 IBAction 即可解决。太尴尬了。
I met this issue and solved it just by reconnected the Button to the IBAction whose name was modified before. So embarrassing.
我认为问题在于您正在将方法 gotoTone: 发送到 Tone 对象,但是该方法是在 Forside 对象中定义的。我不确定为什么会发生这种情况,但我建议检查 xib 文件中的连接。
I think the issue is that you are sending the method gotoTone: to a Tone object, however this method is defined within the Forside object. I'm not sure exectly why this is happening, however I suggest checking the connections within you xib file.
您尚未提供有关如何配置按钮的任何信息,但如果该按钮位于您的 nib 文件中,则按钮目标的标识可能设置为错误的类。因此,请确保按钮发送消息的对象的类是
Forside
而不是Tone
。You haven't provided any information about how your button is configured, but if the button is in your nib file, it seems likely that the identity of the button's target is set to the wrong class. So make sure that the class of the object the button sends its message to is
Forside
rather thanTone
.