有人知道我为什么会收到这个错误吗?
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CustomRaisedTabViewController cancel:]: unrecognized selector sent to instance 0x4d321e0'
这是出错的代码。在我的CustomTabViewController
中发生的。当我点击“取消”按钮时就会出现错误。
-(IBAction)showPostModalViewController {
PostActionModalViewController *addController = [[PostActionModalViewController alloc]
initWithNibName:@"PostActionModalView" bundle:nil];
// Configure the PostAddViewController. In this case, it reports any
// changes to a custom delegate object.
addController.delegate = self;
// Create the navigation controller and present it modally.
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:addController];
[self presentModalViewController:navigationController animated:YES];
UIBarButtonItem *cancelButton =
[[UIBarButtonItem alloc] initWithTitle: @"Cancel"
style: UIBarButtonItemStylePlain
target: self
action: @selector(cancel:)];
addController.navigationItem.rightBarButtonItem = cancelButton;
[cancelButton release];
//[self presentModalViewController:addController animated:true];
[navigationController release];
[addController release];
}
-(IBAction)cancel {
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
@selector
后面删除冒号,它就可以正常工作了。或者,你可以按照jer的建议修改你的cancel
操作。 - sudo rm -rf