From fb70c30845bd774c8b33169d3f0a71a2df5e13b6 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Wed, 7 Feb 2018 16:53:33 -0500 Subject: [ios] Add fall-through single tap to iosapp --- platform/ios/app/MBXViewController.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 0f617188b9..917abb08d6 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -206,6 +206,16 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { } [self presentViewController:alertController animated:YES completion:nil]; } + + // Add fall-through single tap gesture recognizer. This will be called when + // the map view's tap recognizers fail. + UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]; + for (UIGestureRecognizer *gesture in self.mapView.gestureRecognizers) { + if ([gesture isKindOfClass:[UITapGestureRecognizer class]]) { + [singleTap requireGestureRecognizerToFail:gesture]; + } + } + [self.mapView addGestureRecognizer:singleTap]; } - (void)saveState:(__unused NSNotification *)notification @@ -1562,6 +1572,14 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { #pragma mark - User Actions +- (void)handleSingleTap:(UITapGestureRecognizer *)singleTap { + [self.navigationController setNavigationBarHidden:!self.navigationController.navigationBarHidden animated:YES]; + + // This is how you'd get the coordinate for the point where the user tapped: + // CGPoint tapPoint = [singleTap locationInView:self.mapView]; + // CLLocationCoordinate2D tapCoordinate = [self.mapView convertPoint:tapPoint toCoordinateFromView:nil]; +} + - (IBAction)handleLongPress:(UILongPressGestureRecognizer *)longPress { if (longPress.state == UIGestureRecognizerStateBegan) -- cgit v1.2.1