Skip to content

Commit 1a9bbee

Browse files
authored
Merge pull request #551 from fishbrain/bug-dismiss-tap
Fix date picker dismissing when tapping on date picker in .inline style
2 parents bdf810a + 37c9559 commit 1a9bbee

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

CoreActionSheetPicker/CoreActionSheetPicker/Pickers/AbstractActionSheetPicker.m

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,26 +293,26 @@ - (void)showActionSheetPicker {
293293
switch (self.tapDismissAction) {
294294
case TapActionDismiss: {
295295
// add tap dismiss action
296-
self.actionSheet.window.userInteractionEnabled = YES;
296+
self.actionSheet.superview.userInteractionEnabled = YES;
297297
UITapGestureRecognizer *tapAction = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissPicker)];
298298
tapAction.delegate = self;
299-
[self.actionSheet.window addGestureRecognizer:tapAction];
299+
[self.actionSheet.superview addGestureRecognizer:tapAction];
300300
break;
301301
}
302302
case TapActionSuccess: {
303303
// add tap success action with dismissPicker
304-
self.actionSheet.window.userInteractionEnabled = YES;
304+
self.actionSheet.superview.userInteractionEnabled = YES;
305305
UITapGestureRecognizer *tapAction = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionPickerDone:)];
306306
tapAction.delegate = self;
307-
[self.actionSheet.window addGestureRecognizer:tapAction];
307+
[self.actionSheet.superview addGestureRecognizer:tapAction];
308308
break;
309309
}
310310
case TapActionCancel: {
311311
// add tap cancel action with dismissPicker
312-
self.actionSheet.window.userInteractionEnabled = YES;
312+
self.actionSheet.superview.userInteractionEnabled = YES;
313313
UITapGestureRecognizer *tapAction = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionPickerCancel:)];
314314
tapAction.delegate = self;
315-
[self.actionSheet.window addGestureRecognizer:tapAction];
315+
[self.actionSheet.superview addGestureRecognizer:tapAction];
316316
break;
317317
}
318318
};
@@ -798,8 +798,9 @@ - (void)presentPopover:(UIViewController *)viewController {
798798
#pragma mark UIGestureRecognizerDelegate
799799

800800
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
801-
CGPoint location = [gestureRecognizer locationInView:self.toolbar];
802-
return !CGRectContainsPoint(self.toolbar.bounds, location);
801+
CGPoint toolbarLocation = [gestureRecognizer locationInView:self.toolbar];
802+
CGPoint actionSheetLocation = [gestureRecognizer locationInView:self.actionSheet];
803+
return !(CGRectContainsPoint(self.toolbar.bounds, toolbarLocation) || CGRectContainsPoint(self.actionSheet.bgView.frame, actionSheetLocation));
803804
}
804805

805806
@end

0 commit comments

Comments
 (0)