我在运行时遇到此错误:
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7ff70350c8a0 UITableViewCellContentView:0x7ff7058511c0.trailingMargin == UIView:0x7ff705851f00.trailing>
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.
2016-08-29 16:53:12.533 xxxx[7125:4051730] 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:0x7ff705a0aca0 UITableViewCellContentView:0x7ff705853420.trailingMargin == UIView:0x7ff7058546f0.trailing - 10>",
"<NSLayoutConstraint:0x7ff705a0ad90 UITableViewCellContentView:0x7ff705853420.trailingMargin == UIView:0x7ff7058546f0.trailing>"
)
但是,我无法确定它的来源
UITableViewCellContentView:0x7ff705853420.trailingMargin == 的UIView:0x7ff7058546f0.trailing
我在IDE中找不到。我已经尝试在我设置约束的位置搜索代码 - 但就我所知,没有任何与错误匹配的内容。
是否有可能定义了Xcode IDE没有显示的约束?
答案 0 :(得分:1)
当约束中断时,您可以扩展NSLayoutConstraint
并覆盖description
以返回稍微更人性化的信息:
extension NSLayoutConstraint {
override public var description: String {
let id = identifier ?? "NO ID"
return "id: \(id), constant: \(constant)"
}
}
这个繁琐的部分是你必须为每个约束手动设置一个id,尽管你可以通过注释掉扩展来限制所需的工作量,并且只设置与标准约束警告相关的约束的标识符。
答案 1 :(得分:1)
您可以尝试打开MainStoryBoard作为源代码并在那里搜索。问题是你有两个相同的约束(UIView的尾随边距),其中一个是0,另一个是10.它可能没有从故事板的源代码中删除。