From 8c5c4dd5657852dbd82acdf30927d8af9d2f87f6 Mon Sep 17 00:00:00 2001 From: Lloyd Sheng Date: Thu, 11 Apr 2019 16:48:53 +0800 Subject: [ios] Fix issue wrong position of attribution dialog after rotation (#14185) * Fix issue #12897 --- platform/ios/CHANGELOG.md | 1 + platform/ios/src/MGLMapView.mm | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 1f6e8b01c3..72e3e75cb2 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -5,6 +5,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ## 4.11.0 * Fixed an Interface Builder crash when using an `MGLMapView` in a storyboard. ([#14379](https://github.com/mapbox/mapbox-gl-native/pull/14379)) +* Fix a bug that wrong position of attribution dialog after rotation. ([#14185](https://github.com/mapbox/mapbox-gl-native/pull/14185)) ## 4.10.0 diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 232beb9b2e..49218747ae 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -213,6 +213,7 @@ public: @property (nonatomic) NSMutableArray *logoViewConstraints; @property (nonatomic, readwrite) UIButton *attributionButton; @property (nonatomic) NSMutableArray *attributionButtonConstraints; +@property (nonatomic, weak) UIAlertController *attributionController; @property (nonatomic, readwrite) MGLStyle *style; @@ -1016,6 +1017,8 @@ public: } [self updateUserLocationAnnotationView]; + + [self updateAttributionAlertView]; } /// Updates `contentInset` to reflect the current window geometry. @@ -2417,6 +2420,7 @@ public: UIViewController *viewController = [self.window.rootViewController mgl_topMostViewController]; [viewController presentViewController:attributionController animated:YES completion:NULL]; + self.attributionController = attributionController; } - (void)presentTelemetryAlertController @@ -6405,6 +6409,23 @@ public: } } +- (void)updateAttributionAlertView { + if (self.attributionController.presentingViewController) { + self.attributionController.popoverPresentationController.sourceRect = self.attributionButton.frame; + switch (self.attributionButtonPosition) { + case MGLOrnamentPositionTopLeft: + case MGLOrnamentPositionTopRight: + [self.attributionController.popoverPresentationController setPermittedArrowDirections:UIMenuControllerArrowUp]; + break; + case MGLOrnamentPositionBottomLeft: + case MGLOrnamentPositionBottomRight: + [self.attributionController.popoverPresentationController setPermittedArrowDirections:UIMenuControllerArrowDown]; + break; + } + [self.attributionController.popoverPresentationController.containerView setNeedsLayout]; + } +} + - (void)enqueueAnnotationViewForAnnotationContext:(MGLAnnotationContext &)annotationContext { MGLAnnotationView *annotationView = annotationContext.annotationView; -- cgit v1.2.1