Skip to content

Commit

Permalink
iPad dismiss modal ImagePicker clicking outside issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andregrillo committed Feb 3, 2021
1 parent 34865ca commit 013ad8c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion ios/CsZBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ @interface CsZBar ()
@property bool scanInProgress;
@property NSString *scanCallbackId;
@property AlmaZBarReaderViewController *scanReader;
@property (strong, nonatomic) UITapGestureRecognizer *tapOutsideRecognizer;

@end

Expand Down Expand Up @@ -100,7 +101,7 @@ - (void)scan: (CDVInvokedUrlCommand*)command;

self.scanReader.cameraOverlayView = polygonView;
}

[self.viewController.view.window addGestureRecognizer:self.tapBehindGesture];
[self.viewController presentViewController:self.scanReader animated:YES completion:nil];
}
}
Expand Down Expand Up @@ -170,4 +171,27 @@ - (void) readerControllerDidFailToRead:(ZBarReaderController*)reader withRetry:(
}];
}

- (UITapGestureRecognizer*)tapBehindGesture
{
if (_tapOutsideRecognizer == nil)
{
_tapOutsideRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBehindRecognized)];
_tapOutsideRecognizer.numberOfTapsRequired = 1;
_tapOutsideRecognizer.cancelsTouchesInView = NO;
_tapOutsideRecognizer.delegate = self;
}

return _tapOutsideRecognizer;
}

-(void)tapBehindRecognized {
[self.viewController.view.window removeGestureRecognizer:self.tapBehindGesture];
self.scanInProgress = NO;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}

@end

0 comments on commit 013ad8c

Please sign in to comment.