我有一個UITableView,其內容有些動態。似乎每次我調整他們的時候,我打這個錯誤:如何判斷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
。我嘗試從updateConstraints
上的單元格contentView
中刪除所有約束條件。我試過只是打電話beginUpdates
和endUpdates
- 在這種情況下,updateConstraints
永遠不會被稱爲&約束不重新評估。
我不知所措,在這裏。如果沒有自定義單元格,只需調用begin/endUpdates來觸發重新計算單元格的尺寸。我現在怎麼做?
您需要根據需要正確設置單元格的約束條件,然後需要正確計算高度。 – TamilKing 2015-01-21 04:25:42
@TamilKing我正在討論iOS 8中的自動調整表格視圖單元格。查看視頻以瞭解*什麼是表格和集合視圖中的新增內容*來自WWDC 2014. – 2015-01-21 04:30:26
刪除單元格並將其添加回新合同 並給單元格高度HeightForRowAtIndexPath – Shoaib 2015-01-21 04:31:41