Skip to content

Commit

Permalink
Merge pull request #551 from fishbrain/bug-dismiss-tap
Browse files Browse the repository at this point in the history
Fix date picker dismissing when tapping on date picker in .inline style
  • Loading branch information
Wei18 authored Feb 5, 2024
2 parents bdf810a + 37c9559 commit 1a9bbee
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,26 +293,26 @@ - (void)showActionSheetPicker {
switch (self.tapDismissAction) {
case TapActionDismiss: {
// add tap dismiss action
self.actionSheet.window.userInteractionEnabled = YES;
self.actionSheet.superview.userInteractionEnabled = YES;
UITapGestureRecognizer *tapAction = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissPicker)];
tapAction.delegate = self;
[self.actionSheet.window addGestureRecognizer:tapAction];
[self.actionSheet.superview addGestureRecognizer:tapAction];
break;
}
case TapActionSuccess: {
// add tap success action with dismissPicker
self.actionSheet.window.userInteractionEnabled = YES;
self.actionSheet.superview.userInteractionEnabled = YES;
UITapGestureRecognizer *tapAction = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionPickerDone:)];
tapAction.delegate = self;
[self.actionSheet.window addGestureRecognizer:tapAction];
[self.actionSheet.superview addGestureRecognizer:tapAction];
break;
}
case TapActionCancel: {
// add tap cancel action with dismissPicker
self.actionSheet.window.userInteractionEnabled = YES;
self.actionSheet.superview.userInteractionEnabled = YES;
UITapGestureRecognizer *tapAction = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionPickerCancel:)];
tapAction.delegate = self;
[self.actionSheet.window addGestureRecognizer:tapAction];
[self.actionSheet.superview addGestureRecognizer:tapAction];
break;
}
};
Expand Down Expand Up @@ -798,8 +798,9 @@ - (void)presentPopover:(UIViewController *)viewController {
#pragma mark UIGestureRecognizerDelegate

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

@end
Expand Down

0 comments on commit 1a9bbee

Please sign in to comment.