【发布时间】:2015-10-23 08:42:09
【问题描述】:
自 iOS 8 发布以来,我经常使用自动调整大小的单元格,但最近我遇到了这样的错误:
2015-07-31 08:25:10.610 Evensity[78297:3090623] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x7fbae3485d50 V:[UITextField:0x7fbae3486ab0(55)]>",
"<NSLayoutConstraint:0x7fbae3424790 V:|-(2)-[UITextField:0x7fbae3486ab0] (Names: '|':UITableViewCellContentView:0x7fbae3486990 )>",
"<NSLayoutConstraint:0x7fbae3487480 V:[UITextField:0x7fbae3486ab0]-(2)-| (Names: '|':UITableViewCellContentView:0x7fbae3486990 )>",
"<NSLayoutConstraint:0x7fbae0c525a0 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fbae3486990(59)]>"
)
这是一个非常简单的单元格,它只包含一个 UITextField,没有其他内容。
从图中很难看出,但文本字段的高度限制为 55,垂直间距限制(顶部和底部)各为 2。由于自定尺寸,iOS 增加了 UIView-Encapsulated-Layout-Height 垂直尺寸约束 59 (55 + 2 + 2)。这对我来说似乎没有冲突,但我仍然在日志中看到此警告。
另外仅供参考,在进入屏幕后会立即出现损坏的约束消息;它不依赖于滚动来导致单元格重用。
我在这里遗漏了什么可以解释这一点,我该如何纠正?从用户的角度来看,一切似乎都按预期工作。但是,我坚信如果自动布局正在向控制台写入警告,我应该纠正它们,因为它们总有一天会成为问题。
【问题讨论】:
-
你有没有想过如何摆脱警告?
标签: uitableview ios8 autolayout interface-builder