如何为我的视图解决自动布局约束

如何为我的视图解决自动布局约束

如何为我的视图解决自动布局约束

我需要您的帮助。 如何解决自动布局的警告。

以下是我的组件层次结构:

视图控制器
   查看
      -查看
        -表格视图
          ---表格单元格
             1.标题标签
             2.编辑按钮
             3.删除按钮

我提供了如下约束:

标题标签:

Leading space to superview
trailing space to Edit button
bottom space to superview
top space to superview  

“编辑”按钮

trailing space to remove button
leading space to title label
bottom space to superview
top space to superview

删除按钮

Trailing space to superview
width = 40
leading space to edit button
align center Y
height = 40

我收到标题标签“编辑和删除按钮”的警告“需要X和宽度”。

有帮助吗?

iamhero3333 回答:如何为我的视图解决自动布局约束

Edit button Width Constraint 设置为40,与“删除”按钮的宽度相同。

编辑按钮

trailing space to remove button
leading space to title label
width = 40  
bottom space to superview
top space to superview

如果按钮宽度不固定,则需要更新 具有优先级的内容 Horizontal值。

  

选择“编辑”按钮,然后将内容拥抱优先级 Horizontal的值250更改为251

OR

  

选择标题标签,然后将内容拥抱优先级 Horizontal的值250更改为249

enter image description here

希望这会有所帮助。

,

我建议您为情节提要板组件使用自动布局固定按钮,重新创建视图,这就是我对组件所做的工作。

对于标题标签:

Constraints for Button

对于按钮:

enter image description here

Alignment for Button

对于“删除”按钮:

enter image description here

最后是解决标签的尾随空间问题。

enter image description here

本文链接:https://www.f2er.com/3168829.html

大家都在问