这是我的布局:
问题是关于第二个自定义单元格。我有一个UIImageView和一个UILabel。我希望在单元格的左侧对齐图像,并在另一个自由空间填充标签。
我录制了一个GIF动画来向您展示过程:
结果还可以。但后来我想为我的自定义单元格选择Detail Accessory选项。
之后我得到了这个:
2016-09-21 11:23:57.976 ODFileManager2[4861:70193] 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:0x7fe62addd190 H:[fileIcon(43)] (Names: fileIcon:0x7fe62addcfc0 )>",
"<NSLayoutConstraint:0x7fe62addf1b0 fileIcon.leading == UITableViewCellContentView:0x7fe62addc2c0.leadingMargin (Names: fileIcon:0x7fe62addcfc0 )>",
"<NSLayoutConstraint:0x7fe62addf340 H:[fileIcon]-(0)-[UILabel:0x7fe62addc7d0'Label'] (Names: fileIcon:0x7fe62addcfc0 )>",
"<NSLayoutConstraint:0x7fe62addf390 UITableViewCellContentView:0x7fe62addc2c0.trailingMargin == UILabel:0x7fe62addc7d0'Label'.trailing>",
"<NSLayoutConstraint:0x7fe62ade5e20 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7fe62addc2c0(48)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fe62addd190 H:[fileIcon(43)] (Names: fileIcon:0x7fe62addcfc0 )>
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.
虽然一切看起来都不错。
答案 0 :(得分:1)
高度存在一些问题,您将其设置为43,但是单元格高度为48。
解决这个问题的方法是:
fileIcon
的底部和顶部约束。答案 1 :(得分:0)
只是你的gif打了个,,你将fileIcon
的顶部和底部放到了单元格的顶部和底部,然后设置了fileIcon
的高度限制到43,但根据警告信息,单元格的高度为48。这就是自动布局无法满足约束的原因。
答案 2 :(得分:0)