我有一个UITableView,其内容有点动态。似乎每次我调整它们时,我都会遇到这个错误:
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:0x15dbabf0 WKWebView:0x15da1650.top == UITableViewCellContentView:0x15eaedb0.topMargin>",
"<NSLayoutConstraint:0x15dbac20 UITableViewCellContentView:0x15eaedb0.bottomMargin == WKWebView:0x15da1650.bottom>",
"<NSLayoutConstraint:0x15db1360 V:[WKWebView:0x15da1650(158)]>",
"<NSLayoutConstraint:0x15ed0c00 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x15eaedb0(43.5)]>"
)
最后一个 - 标记为UIView-Encapsulated-Layout-Height
的那个 - 正在破坏事物。我想摆脱它,或者将它设置为一个突破性的优先级,或者其他东西 - 但我似乎无法告诉UITableView打破它。我在各种观点上尝试了setNeedsUpdateConstraints
和setNeedsLayout
的所有可能组合。我已尝试从contentView
上的单元格updateConstraints
中删除所有约束。我尝试过调用beginUpdates
和endUpdates
- 在这种情况下,updateConstraints
永远不会被调用&amp;约束不会被重新评估。
我在这里不知所措。如果没有自定义单元格,只需调用begin / endUpdates来触发重新计算单元格的尺寸。我现在该怎么办?
答案 0 :(得分:0)
您在内容视图中使用的WKWebView是破坏约束的最可能原因。此外,只有在WebView完成加载后才能计算任何webView的高度。例如,在UIWebView中,UIWebView的高度只能在delgate方法中适当地获取&#34; didFinishLoadingWebView&#34;方法。
此外,&#39; UIView-Encapsulated-Layout-Height&#39;据推测,由于计算出的细胞内在高度可能具有不同的值,因此约束不能得到满足。因此,可以降低相关单元约束的优先级,以允许UIView-Encapsulated-Layout-Height具有优先权。