具有“三列”自动布局的UITableViewCell

具有“三列”自动布局的UITableViewCell,uitableview,autolayout,ios9,Uitableview,Autolayout,Ios9,我有一个UITableViewCell,其布局如下: ----------------------------------- [Label1] [Label2 ][Button1] [Label3] [Label4 ][Button2] [Button3] ------------------------------------ 我想把它看作三列,[Label2]和[Label4]可以有不同的内容,这意味着这些

我有一个UITableViewCell,其布局如下:

-----------------------------------
[Label1] [Label2         ][Button1]
[Label3] [Label4         ][Button2]
                          [Button3]
------------------------------------
我想把它看作三列,[Label2]和[Label4]可以有不同的内容,这意味着这些标签的高度可以改变。[Label1]、[Label3]和[Button1]、[Button2]和[Button3]的高度和宽度是固定的

Column 1 - fixed width
[Label1]
[Label3]

Column 2 - variable width and height
[Label2]
[Label4]

Column 3 - fixed width and height
[Button1]
[Button2]
[Button3]

使用“自动布局”实现此布局的最佳方式是什么?

标签1以固定的宽度和高度限制在单元格内容视图的左侧和顶部

标签3约束在单元格内容视图的左侧,具有固定的宽度和高度

按钮1,2,3约束在单元格内容视图的右侧,并固定宽度和高度。按钮1和2分别垂直居中于标签1和标签3

标签2的前导约束为标签1,尾随约束为按钮1。它的顶部约束到标签1,底部约束到标签3的顶部

标签4的前导约束为标签3,尾随约束为按钮2。它的顶部约束到标签3,底部约束到按钮3的顶部

按钮3底部约束到单元格内容视图的底部

标签2和标签4的行数应设置为0

您可能还希望将标签1-标签3和按钮2-按钮3之间的间距设置为大于或等于8,如果标签2和标签4中没有文本,则需要折叠整个单元格


您的表视图应使用自调整大小的单元格tableView.rowHeight=UITableViewAutomaticDimension。

标签2的底部应约束到标签3的顶部?