Reputation: 23
I receive the following error when trying to show an ActionSheet...
2012-11-16 04:07:03.878 MKS WebTech[814:c07] -[mksWorkOrderViewController _presentActionSheet:asPopoverFromBarButtonItem:orFromRect:inView:withPreferredArrowDirections:passthroughViews:backgroundStyle:animated:]: unrecognized selector sent to instance 0x75a5950
- (IBAction)ActionClick:(id)sender {
popupSheet = [[UIActionSheet alloc] init];
[popupSheet setDelegate:self];
[popupSheet addButtonWithTitle:@"Contact List"];
[popupSheet addButtonWithTitle:@"Zone Descriptions"];
[popupSheet addButtonWithTitle:@"Zone Testing"];
[popupSheet addButtonWithTitle:@"Panels"];
[popupSheet addButtonWithTitle:@"Time Sheet"];
[popupSheet addButtonWithTitle:@"Inventory"];
[popupSheet addButtonWithTitle:@"Other Appt."];
[popupSheet addButtonWithTitle:@"Alarm History"];
[popupSheet addButtonWithTitle:@"Service History"];
[popupSheet addButtonWithTitle:@"Complete"];
[popupSheet addButtonWithTitle:@"Cancel"];
[popupSheet setCancelButtonIndex:10];
// Prepare your action sheet
[popupSheet showFromBarButtonItem:bntAction animated:NO];
[popupSheet release];
}
The error happen "showFromBarButtonItem:bntAction" I also tried with sender but same result
also the canPerformAction fires with no problem...
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
return YES;
}
Upvotes: 1
Views: 385
Reputation: 941
For anyone else who runs into this in the future (as I just did): the problem is that UIActionSheet walks up the responder chain calling -canPerformAction:@selector(_presentActionSheet:asPopover... etc etc) on each.
So since the controller incorrectly responds YES, the UIActionSheet goes ahead and tries to call that method, an implementation doesn't exist, and you hit the error.
The correct fix is to reimplement your -canPerformAction:withSender: to only return YES to things you actually handle.
Upvotes: 0
Reputation: 1417
I had this problem once, it's not the same case, but for me, this worked:
Conclusion: I had connected an object to a variable that doesn't exist.
Otherwise, the code looks fine :)
Upvotes: 1