From 7da7f65579fae412fea0fecd9afc3b56e4577ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sun, 10 May 2015 23:32:38 -0700 Subject: [PATCH] Dismiss attribution popover on rotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Constraints go invalid when rotating an iPad while the popover is visible and anchored to the ℹ️. --- platform/ios/MGLMapView.mm | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index c1ff904cb..5c7e6ad61 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -63,6 +63,7 @@ static NSURL *MGLURLForBundledStyleNamed(NSString *styleName) @property (nonatomic) UIImageView *compass; @property (nonatomic) UIImageView *logoBug; @property (nonatomic) UIButton *attributionButton; +@property (nonatomic) UIActionSheet *attributionSheet; @property (nonatomic) UIPanGestureRecognizer *pan; @property (nonatomic) UIPinchGestureRecognizer *pinch; @property (nonatomic) UIRotationGestureRecognizer *rotate; @@ -306,6 +307,16 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) [_attributionButton addTarget:self action:@selector(showAttribution) forControlEvents:UIControlEventTouchUpInside]; _attributionButton.translatesAutoresizingMaskIntoConstraints = NO; [self addSubview:_attributionButton]; + + _attributionSheet = [[UIActionSheet alloc] initWithTitle:@"Mapbox GL for iOS" + delegate:self + cancelButtonTitle:@"Cancel" + destructiveButtonTitle:nil + otherButtonTitles: + @"© Mapbox", + @"© OpenStreetMap", + @"Improve This Map", + nil]; // setup compass // @@ -647,6 +658,11 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) { _mbglMap->update(); } + + if (self.attributionSheet.visible) + { + [self.attributionSheet dismissWithClickedButtonIndex:self.attributionSheet.cancelButtonIndex animated:YES]; + } } #pragma mark - Life Cycle - @@ -1255,16 +1271,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) - (void)showAttribution { - UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Mapbox GL for iOS" - delegate:self - cancelButtonTitle:@"Cancel" - destructiveButtonTitle:nil - otherButtonTitles: - @"© Mapbox", - @"© OpenStreetMap", - @"Improve This Map", - nil]; - [sheet showFromRect:self.attributionButton.frame inView:self animated:YES]; + [self.attributionSheet showFromRect:self.attributionButton.frame inView:self animated:YES]; } - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex