English 中文(简体)
我为什么在申请中看到以下例外?
原标题:Why am I seeing the following exception within my application?

I m creating an iPhone application. I have two view controllers (the main one and an about window). In the about view controller i have a UIButton which is linking to a IBAction in the view controller.

I m getting:

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

I m 100% sure that everything is linked up correctly in xCode and Interface Builder

非常感谢任何帮助。

Thanks. Daniel

UPDATE:我刚刚发现,它试图指出一个不同的阶层。 但它在IB中的正确性?

最佳回答

您应检查一下,你是否实际创立了“约克”案。 为“File s Owner”设定的类别仅指IB的类别:expect。 但是,装上这一ni子的实际物体可能不是约谈兵。

BTW,“编辑”错误信息,以掩盖某些秘密,是掩盖实际的丑恶和使其他人更难帮助的好办法。

问题回答

错误信息是aboutViewController,但在您的代码中,它的名称是。 AboutViewController. • 确保案件符合相关要求,也符合建筑间财产。

如果你能够正确设立,那么它就是一个“Thing Inside(TM)”。

删除 but。 创造新东西,并重新建立。

确保在Interface Buildinger进行撤离和重载。

Try:

- (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..

如果这不是问题,那么,你需要把申请放在夸张上,而不必按例外情况处理。 然后,你可以核实,行动所针对的对象是否真的是你认为的。





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签