[ios] Constrain compass directly to the top layout guide

In iOS 10, the top layout guide is not always returning the expected
value unless there is a constraint applied directly against it.
This commit is contained in:
Jason Wray
2016-10-20 18:50:00 -04:00
committed by Fredrik Karlsson
parent 13c6648713
commit 40a7e6b414

View File

@@ -773,14 +773,18 @@ public:
[constraintParentView removeConstraints:self.compassViewConstraints];
[self.compassViewConstraints removeAllObjects];
// Work around an apparent iOS 10 bug where the top layout guide isn't always updated
// unless there's an active constraint against it. This means we cannot constrain
// directly to the top of self — instead, we must constrain to the top layout guide's
// bottom offset, then subtract that value from contentInset.
[self.compassViewConstraints addObject:
[NSLayoutConstraint constraintWithItem:compassContainer
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeTop
toItem:viewController.topLayoutGuide
attribute:NSLayoutAttributeBottom
multiplier:1
constant:5 + self.contentInset.top]];
constant:5 + self.contentInset.top - viewController.topLayoutGuide.length]];
[self.compassViewConstraints addObject:
[NSLayoutConstraint constraintWithItem:self