gpt4 book ai didi

ios - 如何在可重用的 UITableViewCell 中设置约束

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:00:14 26 4
gpt4 key购买 nike

我的 xib layout likes under drawing除了“c”的高度常量之外,我还设置了从“a”到“b”到...“e”的约束,以便可以确定单元格的高度。有时“c”会隐藏,因为某些原因,当标签可见时,我将高度常量更改为零和实际高度。

--------------------------------------
UILabel(name-singleline) a
UILabel(title-Multi line) b
UIView(hidden or not) c (default height constant = 80)
-UILabel(content Multi line) d
UILabel(singleline) e
--------------------------------------

但是有个autolayout警告让我抓狂

(
"<NSLayoutConstraint:0x15756760 V:[UILabel:0x15756650'XXXX'(15)]>",
"<NSLayoutConstraint:0x15757130 V:[UIView:0x15756ee0(80)]>",
"<NSLayoutConstraint:0x15758060 V:|-(21)-[UILabel:0x15756650'XXXX'] (Names: '|':UITableViewCellContentView:0x157563a0 )>",
"<NSLayoutConstraint:0x15758120 V:[UILabel:0x15756650'XXXX']-(14)-[Project.GWWLabel:0x157573d0'YYYY']>",
"<NSLayoutConstraint:0x157581e0 V:[Project.GWWLabel:0x157573d0'YYYY']-(3)-[UIView:0x15756ee0]>",
"<NSLayoutConstraint:0x15758210 V:[UIView:0x15756ee0]-(8)-[UILabel:0x157569e0'ZZZZ']>",
"<NSLayoutConstraint:0x15758270 V:[UILabel:0x157569e0'ZZZZ']-(18)-| (Names: '|':UITableViewCellContentView:0x157563a0 )>",
"<NSLayoutConstraint:0x1575d760 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x157563a0(139.5)]>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x15757130 V:[UIView:0x15756ee0(80)]>

我也很想知道为什么会这样

最佳答案

试试这个:

将height constraint的priority设置为750如下图当你改变高度常数时它会起作用

enter image description here

关于ios - 如何在可重用的 UITableViewCell 中设置约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31963753/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com