首页 > 解决方案 > 如何为我的视图解决自动布局约束

问题描述

自动布局警告故事板截图我需要你的帮助。如何解决自动布局的警告。

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

View Controller
View
- View
--Table View
---表格单元格
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 和宽度”。

有什么帮助吗?

标签: iosobjective-cios-autolayout

解决方案


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

对于标题标签:

按钮的约束

对于按钮:

在此处输入图像描述

按钮对齐

对于删除按钮:

在此处输入图像描述

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

在此处输入图像描述


推荐阅读