[英]Why am I not seeing a loading screen in my application on OS 3.1, but I am on 4.0?
[英]Why am I seeing the following exception within my application?
我正在创建一个iPhone应用程序。 我有两个视图控制器(主要的一个和一个关于窗口)。 在About视图控制器中,我有一个UIButton,它链接到视图控制器中的IBAction。
我越来越:
2010-08-05 21:40:05.741 appname[9151:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[aboutViewController gotoMain2]: unrecognized selector sent to instance 0x5c09950'
这是代码:
//
// aboutAboutViewController.h
//
// Created by **** on 5/08/10.
// Copyright 2010 ***. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface AboutViewController : UIViewController {
}
- (IBAction)gotoMain2;
@end
And the .m file:
//
// AboutViewController.m
//
// Created by **** on 5/08/10.
// Copyright 2010 ****. All rights reserved.
//
#import "AboutViewController.h"
@implementation AboutViewController
- (IBAction)gotoMain2 {
[self dismissModalViewControllerAnimated:TRUE];
}
@end
我100%确保在xCode和Interface Builder中所有内容都正确链接
任何帮助是极大的赞赏
谢谢。 丹尼尔
更新:我刚刚发现它试图指向一个不同的类。但是在IB中它是正确的???
您应该检查在哪里实际创建AboutViewController实例。 设置“文件所有者”的类只是告诉IB 期望什么类。 但是可能加载此笔尖的实际对象不是AboutViewController。
顺便说一句,“编辑”错误消息以隐藏一些秘密是掩盖实际错误并使其他人更难以帮助的好方法。 :)
该错误消息显示aboutViewController
,但是在您的代码中它名为AboutViewController
。 确保大小写匹配,同样在Interface Builder属性中。
如果安装正确,则为“ Thing Inside(TM)”。
删除按钮。 创建一个新的,然后重新设置。
确保退出并在Interface Builder中重新加载。
尝试:
- (IBAction)goToMain2:(id)sender;
和
- (IBAction)goToMain2:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
显然,您没有将其正确链接,否则您将不会获得异常。
我不介意打赌错误消息看起来更像这样:
-[AboutViewController gotoMain2:]: unrecognized selector sent to instance 0x5c09950
^^ colon here
我认为的原因是通常这样声明IBAction
:
-(IBAction) doAnAction: (id) sender;
^^^^^^^^^^^^^ actions take a parameter which is the object that sends them..
如果这不是问题,则需要在调试器中运行带有异常中断的应用程序。 然后,您可以检查将动作发送到的对象是否确实是您认为的样子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.