Reputation: 8834
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];
}
}
// ...
Upvotes: 0
Views: 312
Reputation: 8834
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.
Upvotes: 0