summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2018-02-07 16:53:33 -0500
committerJason Wray <jason@mapbox.com>2018-02-07 17:00:57 -0500
commitfb70c30845bd774c8b33169d3f0a71a2df5e13b6 (patch)
treec21c930444a6dd543ae0d7e13cb97250d8b95c2c
parent62ae0738e8a3d1b3e4b661fa7e8d8bb1d6339c51 (diff)
downloadqtlocation-mapboxgl-upstream/fb-add-single-tap-iosapp.tar.gz
[ios] Add fall-through single tap to iosappupstream/fb-add-single-tap-iosapp
-rw-r--r--platform/ios/app/MBXViewController.m18
1 files changed, 18 insertions, 0 deletions
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)