我使用自动布局设置了自定义UITableViewCell
。但是,运行代码时,会出现以下自动布局错误:
"<NSLayoutConstraint:0x7fd6e3565900 UIImageView:0x7fd6e3566360.width == 0.833333*UIImageView:0x7fd6e3566360.height>",
"<NSLayoutConstraint:0x7fd6e3566290 V:|-(0)-[UIImageView:0x7fd6e3566360] (Names: '|':UIView:0x7fd6e3579050 )>",
"<NSLayoutConstraint:0x7fd6e3563e70 H:[UIImageView:0x7fd6e3566360]-(0)-| (Names: '|':UIView:0x7fd6e3579050 )>",
"<NSLayoutConstraint:0x7fd6e3563ec0 H:|-(0)-[UIImageView:0x7fd6e3566360] (Names: '|':UIView:0x7fd6e3579050 )>",
"<NSLayoutConstraint:0x7fd6e3564140 V:[UIImageView:0x7fd6e3566360]-(8)-[UILabel:0x7fd6e3565560'Hello']>",
"<NSLayoutConstraint:0x7fd6e35642d0 UIButton:0x7fd6e356b2a0.bottom == UIView:0x7fd6e3579050.bottom>",
"<NSLayoutConstraint:0x7fd6e3564320 V:[UILabel:0x7fd6e3565560'Hello']-(8)-[UIButton:0x7fd6e356b2a0]>",
"<NSLayoutConstraint:0x7fd6e35676d0 H:|-(5)-[UIView:0x7fd6e3579050] (Names: '|':UIView:0x7fd6e1de1370 )>",
"<NSLayoutConstraint:0x7fd6e3567720 V:|-(5)-[UIView:0x7fd6e3579050] (Names: '|':UIView:0x7fd6e1de1370 )>",
"<NSLayoutConstraint:0x7fd6e3567770 H:[UIView:0x7fd6e3579050]-(5)-| (Names: '|':UIView:0x7fd6e1de1370 )>",
"<NSLayoutConstraint:0x7fd6e35677c0 V:[UIView:0x7fd6e3579050]-(5)-| (Names: '|':UIView:0x7fd6e1de1370 )>",
"<NSLayoutConstraint:0x7fd6e3567980 V:|-(0)-[UIView:0x7fd6e1de1370] (Names: '|':UITableViewCellContentView:0x7fd6e3568fe0 )>",
"<NSLayoutConstraint:0x7fd6e35679d0 H:[UIView:0x7fd6e1de1370]-(0)-| (Names: '|':UITableViewCellContentView:0x7fd6e3568fe0 )>",
"<NSLayoutConstraint:0x7fd6e3567a20 V:[UIView:0x7fd6e1de1370]-(0)-| (Names: '|':UITableViewCellContentView:0x7fd6e3568fe0 )>",
"<NSLayoutConstraint:0x7fd6e3567a70 H:|-(0)-[UIView:0x7fd6e1de1370] (Names: '|':UITableViewCellContentView:0x7fd6e3568fe0 )>",
"<NSLayoutConstraint:0x7fd6e370c0b0 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fd6e3568fe0(363.5)]>",
"<NSLayoutConstraint:0x7fd6e370c060 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x7fd6e3568fe0(375)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fd6e3565900 UIImageView:0x7fd6e3566360.width == 0.833333*UIImageView:0x7fd6e3566360.height>
正如你所看到的,它试图打破我为UIImageView
设置的5:6比例(虽然它在屏幕上的效果没有明显差异)。我需要确保这个5:6的比例保持不变,但是,我对它的相互矛盾有点困惑。任何帮助将不胜感激。
答案 0 :(得分:1)
结果我必须设置直接附加到UIImageView
的垂直约束,其优先级略低于UIImageView
的方面约束。