xcode iAction无法识别的选择器已发送到实例
我的代码中的和iAction有问题。每次单击按钮时,都会出现此异常:xcode iAction无法识别的选择器已发送到实例,xcode,uitableview,ibaction,Xcode,Uitableview,Ibaction,我的代码中的和iAction有问题。每次单击按钮时,都会出现此异常: 2013-01-15 22:25:00.798 FitnessApp[3478:c07] -[__NSCFString cancel:]: unrecognized selector sent to instance 0x93a7e50 2013-01-15 22:25:00.800 FitnessApp[3478:c07] *** Terminating app due to uncaught exception
2013-01-15 22:25:00.798 FitnessApp[3478:c07] -[__NSCFString cancel:]: unrecognized selector sent to instance 0x93a7e50
2013-01-15 22:25:00.800 FitnessApp[3478:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString cancel:]: unrecognized selector sent to instance 0x93a7e50'
我已经搜索了这个错误。然而,这里关于stackoverflow的解决方案不起作用。
我的连接都设置正确。没有可疑的联系之类的
我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
[self setTitle:NSLocalizedString(@"Placeholder_Description", nil)];
[self.navigationController setToolbarHidden:NO];
[self.navigationController.toolbar setTintColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1]];
[self.buttonCancel setTarget:NSLocalizedString(@"Cancel_Button", nil)];
[self.buttonSave setTarget:NSLocalizedString(@"Save_Button", nil)];
[self.textViewDescription.layer setBorderColor:[[UIColor grayColor] CGColor]];
[self.textViewDescription.layer setBorderWidth:1.0];
[self.textViewDescription.layer setCornerRadius:8.0f];
[self.textViewDescription.layer setMasksToBounds:YES];
[self.textViewDescription setText:[self textViewDescriptionText]];
}
- (IBAction)cancel:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)save:(id)sender {
[self.delegate doSaveDescription:self withDescription:[self.textViewDescription text]];
[self dismissViewControllerAnimated:YES completion:nil];
}
我制作了一些nslog来发现iAction是个问题,因为在单击按钮之后,从来没有输出,只有一个例外。
那么,如果连接设置正确,我该怎么办呢?我发现问题只是出现在UIBarButtonItem上,而不是出现在普通按钮上。如果我把普通按钮连接到IBActions上,一切都很好。那么,为什么它不适用于维吾尔人呢?天哪,问题解决了。。。。。setTitle而不是setTarget…..您应该回答自己的问题,以防这可能在将来帮助其他人:)