Skip to content

Commit

Permalink
Merge pull request #15 from OutSystems/fix/RMET-527-iPad-dismiss-moda…
Browse files Browse the repository at this point in the history
…l-issue

RMET-527 - iPad dismiss modal ImagePicker clicking outside issue fix
  • Loading branch information
andregrillo authored Feb 3, 2021
2 parents 34865ca + 013ad8c commit a3cffd9
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 a3cffd9

Please sign in to comment.