diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-05-10 23:32:38 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2015-05-10 23:32:38 -0700 |
commit | 7da7f65579fae412fea0fecd9afc3b56e4577ca6 (patch) | |
tree | a47631be1cea01ec24a369a1d34f28a4963b441a | |
parent | 005af44efb9536bb3c5645858f1088bde21092d1 (diff) | |
download | qtlocation-mapboxgl-7da7f65579fae412fea0fecd9afc3b56e4577ca6.tar.gz |
Dismiss attribution popover on rotation
Constraints go invalid when rotating an iPad while the popover is visible and anchored to the ℹ️.
-rw-r--r-- | platform/ios/MGLMapView.mm | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index c1ff904cb7..5c7e6ad61e 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 |