我的代码中存在IBAction问题。每次我点击按钮时都会显示此例外:
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来发现IBAction是问题,因为点击按钮后没有输出,只是例外。 那么,如果连接设置正确,我该怎么办?