summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2018-02-07 16:53:33 -0500
committerJulian Rex <julian.rex@mapbox.com>2018-02-09 16:33:29 -0500
commitbd8c5ea4620d68f1717092ab88ba585fb90c55f5 (patch)
tree0b9a7a543c353ce26cfe2daaeb3f38da1e42fe03
parent5b6252ff06a3f2bdfd2c87789bceb79882cb1cef (diff)
downloadqtlocation-mapboxgl-bd8c5ea4620d68f1717092ab88ba585fb90c55f5.tar.gz
[ios] Add fall-through single tap to 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 d452d152cc..8146e62a89 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -204,6 +204,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
@@ -1558,6 +1568,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)