表格视图单元格 - 自动布局约束歧义

时间:2018-03-02 04:51:57

标签: ios xcode uitableview autolayout

我尝试创建自定义表格视图单元格,其中包含一个图像视图和三个标签。

以下是相同的屏幕截图:

enter image description here

这些是我的约束:

enter image description here

我在控制台中收到以下错误:

[LayoutConstraints]无法同时满足约束。     可能至少以下列表中的一个约束是您不想要的约束。     试试这个:         (1)看看每个约束,并试图找出你不期望的;         (2)找到添加了不需要的约束或约束的代码并修复它。

"<NSLayoutConstraint:0x1c4090a40 'Bottom' V:[UILabel:0x103e0b220'Snacks']-(15)-|   (active, names: '|':UITableViewCellContentView:0x103e097d0 )>",
"<NSLayoutConstraint:0x1c4090040 'CategoryLabelHeight' UILabel:0x103e0b220'Snacks'.height == 20   (active)>",
"<NSLayoutConstraint:0x1c40909a0 'CategoryLabelTop' V:[UILabel:0x103e0ad40'Frito Lay']-(0)-[UILabel:0x103e0b220'Snacks']   (active)>",
"<NSLayoutConstraint:0x1c408fcd0 'MakerLabelHeight' UILabel:0x103e0ad40'Frito Lay'.height == 25   (active)>",
"<NSLayoutConstraint:0x1c4090950 'MakerLabelTop' V:[UILabel:0x103e0aa60'Lays Potato Chips, Classi...']-(0)-[UILabel:0x103e0ad40'Frito Lay']   (active)>",
"<NSLayoutConstraint:0x1c408fc30 'NameLabelHeight' UILabel:0x103e0aa60'Lays Potato Chips, Classi...'.height == 30   (active)>",
"<NSLayoutConstraint:0x1c40906d0 'NameLabelTop' V:|-(15)-[UILabel:0x103e0aa60'Lays Potato Chips, Classi...']   (active, names: '|':UITableViewCellContentView:0x103e097d0 )>",
"<NSLayoutConstraint:0x1c8091cb0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x103e097d0.height == 105   (active)>"

将尝试通过违反约束来恢复:

<NSLayoutConstraint:0x1c408fc30 'NameLabelHeight' UILabel:0x103e0aa60'Lays Potato Chips, Classi...'.height == 30   (active)>

我在Xcode中也遇到以下错误:

enter image description here

  1. 我试着在网上阅读有关UIView-Encapsulated-Layout-Height的内容,但我找不到具体的内容。关于它的任何指示?
  2. 已经实现了缺失约束下提到的约束。为什么还是这样说呢?
  3. estimatedRowHeight的值是否会影响任何内容?
  4. 我错过了什么?

0 个答案:

没有答案
相关问题