前沿的自动布局约束

时间:2018-12-31 14:21:53

标签: ios uiview autolayout storyboard ios-autolayout

我有3个UIViews-view1,view2,view3。我在情节提要中设置了约束,如下所示:

  1. view1.leading = safeArea。Lead + 0(约束1作为IBOutlet),
  2. view2.leading = view1。Lead,
  3. view3.leading = view2.lead

接下来,我在代码中更改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)>

我在做什么错了?

1 个答案:

答案 0 :(得分:1)

添加评论作为答案,以方便其他人搜索

该错误似乎使您对view1有2个前导约束,其中一个约束现在具有5的常数。