我有3个UIViews-view1,view2,view3。我在情节提要中设置约束如下:
view1.leading = safeArea.leading + 0(约束1为IBOutlet),
view2.leading = view1.leading,
view3.leading = view2.leading
接下来,我在代码中的constraint1中更改常量。我希望view1,view2,view3在view1.leading更改时自动重新对齐。但是相反,我得到了自动布局错误:
[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.
(
"<NSLayoutConstraint:0x283317a70 UIView:0x10321f7d0.leading == UILayoutGuide:0x28290ddc0'UIViewSafeAreaLayoutGuide'.leading (active)>",
"<NSLayoutConstraint:0x283316bc0 UIView:0x10321f7d0.leading == UILayoutGuide:0x28290ddc0'UIViewSafeAreaLayoutGuide'.leading + 5 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x283316bc0 UIView:0x10321f7d0.leading == UILayoutGuide:0x28290ddc0'UIViewSafeAreaLayoutGuide'.leading + 5 (active)>
我究竟做错了什么?
最佳答案
添加评论作为答案,以方便其他人搜索
该错误看起来像您在view1
上有2个主要约束,其中一个约束现在具有常量5。