Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios] Fix issue wrong position of attribution dialog after rotation #14185

Merged
merged 3 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 21 additions & 0 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ @interface MGLMapView () <UIGestureRecognizerDelegate,
@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;

Expand Down Expand Up @@ -1016,6 +1017,8 @@ - (void)layoutSubviews
}

[self updateUserLocationAnnotationView];

[self updateAttributionAlertView];
}

/// Updates `contentInset` to reflect the current window geometry.
Expand Down Expand Up @@ -2417,6 +2420,7 @@ - (void)showAttribution:(id)sender

UIViewController *viewController = [self.window.rootViewController mgl_topMostViewController];
[viewController presentViewController:attributionController animated:YES completion:NULL];
self.attributionController = attributionController;
}

- (void)presentTelemetryAlertController
Expand Down Expand Up @@ -6405,6 +6409,23 @@ - (void)updateCalloutView
}
}

- (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;
Expand Down