From 27f77b6bfa6b41676c2df3bb8b18fd902d4c6951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Tue, 26 Apr 2016 00:02:59 -0700 Subject: [PATCH] [ios] Hide compass from VoiceOver when pointing north Fixes #4820. --- platform/ios/src/MGLMapView.mm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index f2107eb3c..671fd51ef 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -434,7 +434,6 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) _compassView.alpha = 0; _compassView.userInteractionEnabled = YES; [_compassView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleCompassTapGesture:)]]; - _compassView.isAccessibilityElement = YES; _compassView.accessibilityTraits = UIAccessibilityTraitButton; _compassView.accessibilityLabel = NSLocalizedStringWithDefaultValue(@"COMPASS_A11Y_LABEL", nil, nil, @"Compass", @"Accessibility label"); _compassView.accessibilityHint = NSLocalizedStringWithDefaultValue(@"COMPASS_A11Y_HINT", nil, nil, @"Rotates the map to face due north", @"Accessibility hint"); @@ -4278,12 +4277,14 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) - (void)updateCompass { - CLLocationDirection degrees = mbgl::util::wrap(-self.direction, 0., 360.); - self.compassView.transform = CGAffineTransformMakeRotation(MGLRadiansFromDegrees(degrees)); + CLLocationDirection direction = self.direction; + CLLocationDirection plateDirection = mbgl::util::wrap(-direction, 0., 360.); + self.compassView.transform = CGAffineTransformMakeRotation(MGLRadiansFromDegrees(plateDirection)); - self.compassView.accessibilityValue = [_accessibilityCompassFormatter stringFromDirection:self.direction]; + self.compassView.isAccessibilityElement = direction > 0; + self.compassView.accessibilityValue = [_accessibilityCompassFormatter stringFromDirection:direction]; - if (_mbglMap->getBearing() && self.compassView.alpha < 1) + if (direction > 0 && self.compassView.alpha < 1) { [UIView animateWithDuration:MGLAnimationDuration delay:0 @@ -4294,7 +4295,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) } completion:nil]; } - else if (_mbglMap->getBearing() == 0 && self.compassView.alpha > 0) + else if (direction == 0 && self.compassView.alpha > 0) { [UIView animateWithDuration:MGLAnimationDuration delay:0