summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLloyd Sheng <i@lloydsheng.com>2019-04-11 16:48:53 +0800
committerGitHub <noreply@github.com>2019-04-11 16:48:53 +0800
commit8c5c4dd5657852dbd82acdf30927d8af9d2f87f6 (patch)
treea01649ade7cb2ea4f494fb27748eae32c594ab7f
parent82b5d8e5c7c4801391cec0e52bfd7513b8a6ad6d (diff)
downloadqtlocation-mapboxgl-8c5c4dd5657852dbd82acdf30927d8af9d2f87f6.tar.gz
[ios] Fix issue wrong position of attribution dialog after rotation (#14185)
* Fix issue #12897
-rw-r--r--platform/ios/CHANGELOG.md1
-rw-r--r--platform/ios/src/MGLMapView.mm21
2 files changed, 22 insertions, 0 deletions
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<NSLayoutConstraint *> *logoViewConstraints;
@property (nonatomic, readwrite) UIButton *attributionButton;
@property (nonatomic) NSMutableArray<NSLayoutConstraint *> *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;