Quelqu'un sait pourquoi je reçois cette erreur?Sélecteur non reconnu envoyé à l'instance
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CustomRaisedTabViewController cancel:]: unrecognized selector sent to instance 0x4d321e0'
C'est le code où il échoue. C'est dans mon CustomTabViewController
. L'erreur se produit lorsque je clique sur le bouton "Annuler".
-(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];
}
Vous essayez d'appeler un sélecteur qui a un argument, alors que votre méthode actuelle ne dispose pas d'un argument. Supprimez simplement le deux-points après 'cancel:' dans votre @ selector et cela devrait fonctionner correctement. Alternativement, vous pouvez modifier votre action 'cancel' comme indiqué ci-dessous. –