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

问题描述 投票:0回答:2

warnings for autolayout Storyboard screenshot我需要您的帮助。如何解决自动布局的警告。

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

查看控制器视图-查看-表视图---表单元格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和宽度”。

有帮助吗?

ios objective-c ios-autolayout
2个回答
0
投票

设置[Edit button宽度限制]如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

希望这会有所帮助。


0
投票

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

标题标签:

Constraints for Button

对于按钮:

enter image description here

Alignment for Button

对于删除按钮:

enter image description here

最后是标签的尾随空间问题修复。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.