【发布时间】:2016-09-21 04:58:12
【问题描述】:
这是我的布局:
问题是关于第二个自定义单元格。我有一个 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.
虽然一切看起来都还不错。
【问题讨论】:
-
你有没有尝试在将单元格的附件放在那里后添加约束?
-
我同意@Tj3n,但这个警告背后一定有一些解释。
-
你是动态增加单元格的高度吗?
-
您可能添加了一个您可能不需要的约束。这意味着,删除约束不会影响您的视图,并且会满足所有设备。
-
@Tj3n,是的,没有区别。
标签: ios objective-c xcode uitableview autolayout