0

I have an action sheet that when one of it's options are clicked successfully calls clickedButtonAtIndex when run in the simulator but when testing on an iPhone (5s in Xcode 6) it doesn't reach the callback.

The header...

@protocol SGETriggerToolBarDelegate
-(void)showCustomEditView;
@end

@interface SGETriggerToolBarController : UIViewController <UIActionSheetDelegate>

@property (nonatomic, assign) id <SGETriggerToolBarDelegate> delegate;
@property (nonatomic, strong) UIToolbar *toolbar;

in the implementation...

// in xController.m
// ...
- (void)triggerButtonHandler
{
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select an event type"
                                                             delegate:self
                                                    cancelButtonTitle:nil
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:nil];
    for (SGETrigger *trigger in triggers)  {
        [actionSheet addButtonWithTitle:trigger.name];
    }

    [actionSheet addButtonWithTitle:@"Cancel"];
    actionSheet.cancelButtonIndex = triggers.count;

    [actionSheet showFromToolbar:self.toolbar];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == [actionSheet cancelButtonIndex]) {
        return;
    } else {
        selectedTrigger = triggers[buttonIndex];
        triggerButton.title = [NSString stringWithFormat:@"• %@ •", selectedTrigger.name];
        [delegate showCustomEditView];
    }
}
// ...
kreek
  • 8,394
  • 8
  • 39
  • 64
  • 1
    FYI - combine the two "Cancel" button lines: `actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:@"Cancel"];`. – rmaddy Sep 17 '14 at 02:19

1 Answers1

0

If you get "Presenting action sheet clipped by its superview. Some controls might not respond to touches"

Replacing...

[actionSheet showFromToolbar:self.toolbar];

with

[actionSheet showInView:[UIApplication sharedApplication].keyWindow];

solved this for me.

kreek
  • 8,394
  • 8
  • 39
  • 64