我在TableViewCell中有一個動態大小的標籤。我已將它固定到上,下,左和右,並將行設置爲0,它工作正常。接下來,我在標籤下面添加一個按鈕並將其固定到頂部和左側。並修復寬度和高度。但我在運行時動態添加按鈕TableViewCell
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:0x7fcbc302f600 UILabel:0x7fcbc3034010'Digestion of food in the...'.top == UITableViewCellContentView:0x7fcbc30334a0.topMargin>",
"<NSLayoutConstraint:0x7fcbc3037e30 UITableViewCellContentView:0x7fcbc30334a0.bottomMargin == UILabel:0x7fcbc3034010'Digestion of food in the...'.bottom + 38>",
"<NSLayoutConstraint:0x7fcbc303a920 'UIView-Encapsulated-Layout-Height' V: [UITableViewCellContentView:0x7fcbc30334a0(43.5)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fcbc3037e30
UITableViewCellContentView:0x7fcbc30334a0.bottomMargin ==
UILabel:0x7fcbc3034010'Digestion of food in the...'.bottom + 38>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. Here is the screenshot of my layout
得到一個錯誤,我應該刪除哪些約束?我認爲我沒有添加額外的約束
細胞高度動態化標籤的大小。我只想讓按鈕出現在標籤文字下方。固定在標籤的頂部 –
然後,應將按鈕的頂部固定到標籤的底部。這是一個自定義單元格,我想對不對?你可以顯示你的佈局的屏幕?確保標籤高度不超過單元的高度。 – jalone
你可以檢查一次佈局嗎? –