diff options
author | Fredrik Karlsson <bjorn.fredrik.karlsson@gmail.com> | 2016-11-15 22:51:35 +0100 |
---|---|---|
committer | Fredrik Karlsson <bjorn.fredrik.karlsson@gmail.com> | 2016-11-15 22:51:35 +0100 |
commit | be1e6c4b6f5018e6142c20ca58904376f42d4108 (patch) | |
tree | a830ddd9e77885f1a45d00a7712c741876372e9d | |
parent | 33fd3ee93ab1fa1d3ac97e00186bfe5a720b88f9 (diff) | |
download | qtlocation-mapboxgl-upstream/fb-ui-constraints.tar.gz |
[ios] simplified constraints and fixed regressionupstream/fb-ui-constraints
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index ee7f98976c..f9c3f946eb 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -763,26 +763,16 @@ public: - (void)updateConstraints { - // If we have a view controller reference and its automaticallyAdjustsScrollViewInsets - // is set to YES, use its view as the parent for constraints. -[MGLMapView adjustContentInset] - // already take top and bottom layout guides into account. If we don't have a reference, apply - // constraints against ourself to maintain placement of the subviews. - // - UIViewController *viewController = self.viewControllerForLayoutGuides; - BOOL useLayoutGuides = viewController.view && viewController.automaticallyAdjustsScrollViewInsets; - UIView *view = useLayoutGuides ? viewController.view : self; - // compass // - UIView *compassContainer = self.compassView.superview; - [view removeConstraints:self.compassViewConstraints]; + [self removeConstraints:self.compassViewConstraints]; [self.compassViewConstraints removeAllObjects]; [self.compassViewConstraints addObject: - [NSLayoutConstraint constraintWithItem:compassContainer + [NSLayoutConstraint constraintWithItem:self.compassView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual - toItem:view + toItem:self attribute:NSLayoutAttributeTop multiplier:1 constant:5 + self.contentInset.top]]; @@ -791,14 +781,14 @@ public: [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual - toItem:compassContainer + toItem:self.compassView attribute:NSLayoutAttributeTrailing multiplier:1 constant:5 + self.contentInset.right]]; UIImage *compassImage = self.compassView.image; [self.compassViewConstraints addObject: - [NSLayoutConstraint constraintWithItem:compassContainer + [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil @@ -807,18 +797,18 @@ public: constant:compassImage.size.width]]; [self.compassViewConstraints addObject: - [NSLayoutConstraint constraintWithItem:compassContainer + [NSLayoutConstraint constraintWithItem:self.compassView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:compassImage.size.height]]; - [view addConstraints:self.compassViewConstraints]; + [self addConstraints:self.compassViewConstraints]; // logo bug // - [view removeConstraints:self.logoViewConstraints]; + [self removeConstraints:self.logoViewConstraints]; [self.logoViewConstraints removeAllObjects]; [self.logoViewConstraints addObject: @@ -838,11 +828,11 @@ public: attribute:NSLayoutAttributeLeading multiplier:1 constant:8 + self.contentInset.left]]; - [view addConstraints:self.logoViewConstraints]; + [self addConstraints:self.logoViewConstraints]; // attribution button // - [view removeConstraints:self.attributionButtonConstraints]; + [self removeConstraints:self.attributionButtonConstraints]; [self.attributionButtonConstraints removeAllObjects]; [self.attributionButtonConstraints addObject: @@ -862,7 +852,7 @@ public: attribute:NSLayoutAttributeTrailing multiplier:1 constant:8 + self.contentInset.right]]; - [view addConstraints:self.attributionButtonConstraints]; + [self addConstraints:self.attributionButtonConstraints]; [super updateConstraints]; } |