Как исправить конфликт ограничений TableViewCell? - PullRequest
0 голосов
/ 29 января 2020

Во время анимации табличных ячеек по какой-то причине левая круговая кнопка начала ломать автопроявление

enter image description here

В журнале появляется следующая ошибка

2020-01-28 22:09:56.581680-0500 Zenn[19786:13017249] [LayoutConstraints] 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. 
(
    "<NSLayoutConstraint:0x600000122670 UIButton:0x7f92b3c10520'Button'.height == 30   (active)>",
    "<NSLayoutConstraint:0x60000012d900 V:[UIStackView:0x7f92b3c18670]-(10)-|   (active, names: '|':UITableViewCellContentView:0x7f92b3c18cd0 )>",
    "<NSLayoutConstraint:0x60000012d810 V:|-(10)-[UIStackView:0x7f92b3c18670]   (active, names: '|':UITableViewCellContentView:0x7f92b3c18cd0 )>",
    "<NSLayoutConstraint:0x60000012eda0 'UISV-canvas-connection' UIStackView:0x7f92b3c1a970.top == UIButton:0x7f92b3c10520'Button'.top   (active)>",
    "<NSLayoutConstraint:0x60000012edf0 'UISV-canvas-connection' V:[UIButton:0x7f92b3c10520'Button']-(0)-|   (active, names: '|':UIStackView:0x7f92b3c1a970 )>",
    "<NSLayoutConstraint:0x60000012f1b0 'UISV-canvas-connection' UILayoutGuide:0x600001b17480'UIViewLayoutMarginsGuide'.top == Zenn.UITextViewCustom:0x7f92b4050c00'Www.google.com \n\n64768695...'.top   (active)>",
    "<NSLayoutConstraint:0x60000012f200 'UISV-canvas-connection' UILayoutGuide:0x600001b17480'UIViewLayoutMarginsGuide'.bottom == Zenn.UITextViewCustom:0x7f92b4050c00'Www.google.com \n\n64768695...'.bottom   (active)>",
    "<NSLayoutConstraint:0x60000012f250 'UISV-canvas-connection' UIStackView:0x7f92b3c18670.top == UIStackView:0x7f92b3c1a970.top   (active)>",
    "<NSLayoutConstraint:0x60000012fac0 'UISV-canvas-connection' V:[UIStackView:0x7f92b3c1d0b0]-(0)-|   (active, names: '|':UIStackView:0x7f92b3c18670 )>",
    "<NSLayoutConstraint:0x600000128050 'UISV-spacing' V:[UIStackView:0x7f92b3c1a970]-(0)-[UIStackView:0x7f92b3c1d0b0]   (active)>",
    "<NSLayoutConstraint:0x60000012efd0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x600001b17480'UIViewLayoutMarginsGuide']-(8)-|   (active, names: '|':UIStackView:0x7f92b3c1d0b0 )>",
    "<NSLayoutConstraint:0x600000139c20 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7f92b3c18cd0.height == 50   (active)>",
    "<NSLayoutConstraint:0x60000012ef30 'UIView-topMargin-guide-constraint' V:|-(8)-[UILayoutGuide:0x600001b17480'UIViewLayoutMarginsGuide']   (active, names: '|':UIStackView:0x7f92b3c1d0b0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600000122670 UIButton:0x7f92b3c10520'Button'.height == 30   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

Похоже, он больше не может удовлетворять требованию установки высоты кнопки равной 30. Но что с ней конфликтует?

enter image description here

1 Ответ

0 голосов
/ 30 января 2020

Внимательно проверьте ваши ограничения и добавьте метод делегата для высоты tableViewCell.

Swift 5

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableView.automaticDimension
}
...