gpt4 book ai didi

ios - UITableViewCell contentView 中的自动布局

转载 作者:行者123 更新时间:2023-11-28 05:57:32 26 4
gpt4 key购买 nike

我正在尝试以编程方式创建约束,以将这个粉红色的 UIView 置于 UITableViewCell 的中心。但是,当我添加约束时,它们不适用,并且我在控制台中收到一条消息,指出某些 NSAutoresizingMaskLayoutConstraints 不能同时满足。

因此,当我设置 cell.contentView.translatesAutoresizingMaskIntoConstraints = false 时,我在控制台中收到此消息:

"Changing the translatesAutoresizingMaskIntoConstraints property of the contentView of a UITableViewCell is not supported and will result in undefined behavior, as this property is managed by the owning UITableViewCell".

View 确实居中,但控制台显示我不应该更改此属性。

我怎样才能做到这一点?

Before setting the property to false

After setting the property to false

非常感谢。

最佳答案

此外,请确保在您的单元格的 xib 中,应选择 Layout 以

“自动调整蒙版”

而不是“推断(自动调整掩码)”

如图所示

enter image description here

关于ios - UITableViewCell contentView 中的自动布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51021203/

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