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

Commit

Permalink
[ios] Fix issue wrong position of attribution dialog after rotation (#…
Browse files Browse the repository at this point in the history
…14185)

* Fix issue #12897
  • Loading branch information
lloydsheng authored Apr 11, 2019
1 parent 82b5d8e commit 8c5c4dd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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

0 comments on commit 8c5c4dd

Please sign in to comment.