summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-11-20 13:16:20 +0100
committerGitHub <noreply@github.com>2016-11-20 13:16:20 +0100
commit307f8e4f41a440fdfcd9c7bb1833110ab9278ccf (patch)
tree4948af91ab12c56fc52a9bb2759cb315b1e4cd79 /platform
parente858dba86def62967865856f4dbbe1b24663cb45 (diff)
downloadqtlocation-mapboxgl-307f8e4f41a440fdfcd9c7bb1833110ab9278ccf.tar.gz
[ios] simplified constraints and fixed regression 6954 (#7084)
* [ios] simplified constraints and fixed regression 6954 * [ios] removed excessive constraints * [ios] removed compass container view
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/src/MGLMapView.mm52
1 files changed, 11 insertions, 41 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index ee7f98976c..e857a9fa4d 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -468,10 +468,8 @@ public:
_compassView.accessibilityTraits = UIAccessibilityTraitButton;
_compassView.accessibilityLabel = NSLocalizedStringWithDefaultValue(@"COMPASS_A11Y_LABEL", nil, nil, @"Compass", @"Accessibility label");
_compassView.accessibilityHint = NSLocalizedStringWithDefaultValue(@"COMPASS_A11Y_HINT", nil, nil, @"Rotates the map to face due north", @"Accessibility hint");
- UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
- [container addSubview:_compassView];
- container.translatesAutoresizingMaskIntoConstraints = NO;
- [self addSubview:container];
+ _compassView.translatesAutoresizingMaskIntoConstraints = NO;
+ [self addSubview:_compassView];
_compassViewConstraints = [NSMutableArray array];
// setup interaction
@@ -763,26 +761,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,34 +779,16 @@ 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
- attribute:NSLayoutAttributeWidth
- relatedBy:NSLayoutRelationEqual
- toItem:nil
- attribute:NSLayoutAttributeNotAnAttribute
- multiplier:1
- constant:compassImage.size.width]];
-
- [self.compassViewConstraints addObject:
- [NSLayoutConstraint constraintWithItem:compassContainer
- 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 +808,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 +832,7 @@ public:
attribute:NSLayoutAttributeTrailing
multiplier:1
constant:8 + self.contentInset.right]];
- [view addConstraints:self.attributionButtonConstraints];
+ [self addConstraints:self.attributionButtonConstraints];
[super updateConstraints];
}