Search code examples
uiactionsheet

unrecognized selector sent to instance UIActionSheet


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;
}

Solution

  • I had this problem once, it's not the same case, but for me, this worked:

    1. Go to Interface Builder
    2. Check ALL objects, the problem for me was that I connected an object to a variable that I later deleted, so it didn't exist.

    Conclusion: I had connected an object to a variable that doesn't exist.

    Otherwise, the code looks fine :)