I need set different constrains for horizontal and vertical orientation by calling mas_remakeConstraints when rotate device.
[self.viewA mas_remakeConstraints:^(MASConstraintMaker *make) {
if (isHorizontal) {
make.left.top.bottom.equalTo(self.view); // left of screen
}
else {
make.left.right.top.equalTo(self.view); // top of screen
}
}];
[self.viewB mas_remakeConstraints:^(MASConstraintMaker *make) {
if (isHorizontal) {
make.right.top.bottom.equalTo(self.view);
make.left.equalTo(self.viewA.mas_right); // right of screen
}
else {
make.left.right.bottom.equalTo(self.view);
make.top.equalTo(self.viewA.mas_bottom); // bottom of screen
}
make.width.height.equalTo(self.viewA);
}];
MASAttachKeys(self.view, self.viewA, self.viewB);
It prints autolayout warning when rotate device to horizontal.
[LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<MASLayoutConstraint:0x1566f780 UIView:self.viewB.bottom == UIView:self.view.bottom>",
"<MASLayoutConstraint:0x1566fc70 UIView:self.viewB.top == UIView:self.viewA.bottom>",
"<MASLayoutConstraint:0x1566c590 UIView:self.viewB.height == UIView:self.viewA.height>",
"<MASLayoutConstraint:0x1555c5c0 UIView:self.viewA.top == UIView:self.view.top>",
"<MASLayoutConstraint:0x1556e3b0 UIView:self.viewA.bottom == UIView:self.view.bottom>",
"<NSLayoutConstraint:0x15552250 UIView:self.view.height == 320>"
)
@iwill you need to run remakeConstraints on the same view, you currently run it once on viewA then once on viewB which will generate two unique sets of constraints.
New Issue Checklist
🚫 If this template is not filled out your issue will be closed with no comment. 🚫
Issue Info
Issue Description
I need set different constrains for horizontal and vertical orientation by calling mas_remakeConstraints when rotate device.
It prints autolayout warning when rotate device to horizontal.