forked from organicmaps/organicmaps
[ios] fix layout crash on the ios 12 on ipad
The exception was rised by the NSLayoutConstrait when the priority is changed (on ipad) after constraint activation. The all of the constraints set up shood be done before activation. Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
parent
a2b642d601
commit
200b433f71
1 changed files with 17 additions and 12 deletions
|
@ -148,24 +148,30 @@ NSString *const kSettingsSegue = @"Map2Settings";
|
||||||
|
|
||||||
- (void)setupPlacePageContainer {
|
- (void)setupPlacePageContainer {
|
||||||
self.placePageContainer = [[TouchTransparentView alloc] initWithFrame:self.view.bounds];
|
self.placePageContainer = [[TouchTransparentView alloc] initWithFrame:self.view.bounds];
|
||||||
|
self.placePageContainer.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
[self.view addSubview:self.placePageContainer];
|
[self.view addSubview:self.placePageContainer];
|
||||||
[self.view bringSubviewToFront:self.placePageContainer];
|
[self.view bringSubviewToFront:self.placePageContainer];
|
||||||
|
|
||||||
self.placePageContainer.translatesAutoresizingMaskIntoConstraints = NO;
|
|
||||||
self.placePageLeadingConstraint = [self.placePageContainer.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor constant:kPlacePageLeadingOffset];
|
self.placePageLeadingConstraint = [self.placePageContainer.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor constant:kPlacePageLeadingOffset];
|
||||||
self.placePageLeadingConstraint.active = YES;
|
if (IPAD)
|
||||||
|
self.placePageLeadingConstraint.priority = UILayoutPriorityDefaultLow;
|
||||||
|
|
||||||
self.placePageWidthConstraint = [self.placePageContainer.widthAnchor constraintEqualToConstant:0];
|
self.placePageWidthConstraint = [self.placePageContainer.widthAnchor constraintEqualToConstant:kPlacePageCompactWidth];
|
||||||
self.placePageTrailingConstraint = [self.placePageContainer.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor];
|
self.placePageTrailingConstraint = [self.placePageContainer.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor];
|
||||||
|
|
||||||
[self.placePageContainer.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor].active = YES;
|
NSLayoutConstraint * topConstraint = [self.placePageContainer.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor];
|
||||||
if (IPAD) {
|
|
||||||
self.placePageLeadingConstraint.priority = UILayoutPriorityDefaultLow;
|
NSLayoutConstraint * bottomConstraint;
|
||||||
[self.placePageContainer.bottomAnchor constraintLessThanOrEqualToAnchor:self.view.bottomAnchor].active = YES;
|
if (IPAD)
|
||||||
}
|
bottomConstraint = [self.placePageContainer.bottomAnchor constraintLessThanOrEqualToAnchor:self.view.bottomAnchor];
|
||||||
else {
|
else
|
||||||
[self.placePageContainer.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES;
|
bottomConstraint = [self.placePageContainer.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor];
|
||||||
}
|
|
||||||
|
[NSLayoutConstraint activateConstraints:@[
|
||||||
|
self.placePageLeadingConstraint,
|
||||||
|
topConstraint,
|
||||||
|
bottomConstraint,
|
||||||
|
]];
|
||||||
|
|
||||||
[self updatePlacePageContainerConstraints];
|
[self updatePlacePageContainerConstraints];
|
||||||
}
|
}
|
||||||
|
@ -178,7 +184,6 @@ NSString *const kSettingsSegue = @"Map2Settings";
|
||||||
|
|
||||||
- (void)updatePlacePageContainerConstraints {
|
- (void)updatePlacePageContainerConstraints {
|
||||||
const BOOL isLimitedWidth = IPAD || self.traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact;
|
const BOOL isLimitedWidth = IPAD || self.traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact;
|
||||||
[self.placePageWidthConstraint setConstant:kPlacePageCompactWidth];
|
|
||||||
|
|
||||||
if (IPAD && self.searchView != nil) {
|
if (IPAD && self.searchView != nil) {
|
||||||
NSLayoutConstraint * leadingToSearchConstraint = [self.placePageContainer.leadingAnchor constraintEqualToAnchor:self.searchView.trailingAnchor constant:kPlacePageLeadingOffset];
|
NSLayoutConstraint * leadingToSearchConstraint = [self.placePageContainer.leadingAnchor constraintEqualToAnchor:self.searchView.trailingAnchor constant:kPlacePageLeadingOffset];
|
||||||
|
|
Loading…
Add table
Reference in a new issue