UIActionSheet event not firing

I have a UIActionSheet to provide user options on a table view controller. I have implemented this before without issue, but for some reason now, my event handler does not fire when a button is clicked. In my header file, I have implemented the proper delegate as follows:

@interface GaugeDetailTableViewController : UITableViewController <UIActionSheetDelegate>

In my implementation, I have the following code to support the action sheet:

  • Add UIView as subView on UIActionSheet
  • how to display only time in UIDatePicker iphone
  • Social action sheet (like on iOS 6)
  • UIActionSheet buttonIndex values faulty when using more than 6 custom buttons?
  • How to add UIActionSheet button check mark?
  • UIActionSheet Crashes on iPad / not iPhone
  • -(void)loadPopup{
    UIActionSheet *popup = [[UIActionSheet alloc]
                            initWithTitle:@"Options"
                            delegate:nil
                            cancelButtonTitle:@"Cancel"
                            destructiveButtonTitle:nil
                            otherButtonTitles:@"Add to Favorites", @"Gauge Detail Help", @"Main Menu", nil];
    popup.actionSheetStyle = UIActionSheetStyleDefault;
    
    [popup showInView:self.view];
    }
    
    -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
        NSLog(@"%d\n", buttonIndex);
    }
    

    The action sheet appears properly on the view controller, but for some reason, the action sheet click event handler is never reached. Any suggestions? Thanks!

    2 Solutions Collect From Internet About “UIActionSheet event not firing”

    You need to set the delegate:

    UIActionSheet *popup = [[UIActionSheet alloc]
                            initWithTitle:@"Options"
                            delegate:self
                            cancelButtonTitle:@"Cancel"
                            destructiveButtonTitle:nil
                            otherButtonTitles:@"Add to Favorites", @"Gauge Detail Help", @"Main Menu", nil];
    popup.actionSheetStyle = UIActionSheetStyleDefault;
    

    It looks like you have forgotten to set the delegate. You need to implement UIActionSheetDelegate (which it looks like you have) and then set the delegate!