我使用snapKit通过AutoLayout创建了一个表格视图动态单元格高度。构建应用程序(Result image)时,一切看起来都很好,但是我收到一些奇怪的调试消息,而且我不知道代码中的问题是什么。
我尝试了setContentCompressionResistancePriority(.defaultHigh,for:.vertical),make.bottom.equalTo(self.contentView).offset(-10).priority(999),但是同样的问题。现在我没有主意。 这就是我设置myView的方式:
我在单元格中设置了myView:
初始化:
contentView.addSubview(myview)
override func updateConstraints() {
if !upCon {
myview.setContentCompressionResistancePriority(.defaultHigh,for: .vertical)
myview.snp.makeConstraints { (make) in
make.top.equalTo(self.contentView).offset(10)
make.left.equalTo(self.contentView).offset(10)
make.width.height.equalTo(50)
make.bottom.equalTo(self.contentView).offset(-10).priority(999)
}
upCon = true
}
super.updateConstraints()
}
我这样设置行高:
myView.tableView.estimatedRowHeight = 100
myView.tableView.rowHeight = UITableView.automaticDimension
因此,我不想在调试日志中看到此信息(如果需要更多代码来重现此问题,我可以共享更多代码):
[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.
(
"<snapKit.LayoutConstraint:0x28127c8a0@ViewController.swift#35 UIView:0x1053738e0.top == UITableViewCellContentView:0x105373e50.top + 10.0>","<snapKit.LayoutConstraint:0x28127c9c0@ViewController.swift#37 UIView:0x1053738e0.height == 50.0>","<snapKit.LayoutConstraint:0x28127ca20@ViewController.swift#38 UIView:0x1053738e0.bottom == UITableViewCellContentView:0x105373e50.bottom - 10.0>","<NSLayoutConstraint:0x2815540f0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x105373e50.height == 70.5 (active)>"
)
Will attempt to recover by breaking constraint
<snapKit.LayoutConstraint:0x28127c9c0@ViewController.swift#37 UIView:0x1053738e0.height == 50.0>
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.
2019-11-06 17:28:04.738171+0200 testImageRotation[19361:1301631] [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.
(
"<snapKit.LayoutConstraint:0x28127cf60@ViewController.swift#35 UIView:0x105376a60.top == UITableViewCellContentView:0x105370a40.top + 10.0>","<snapKit.LayoutConstraint:0x28127d080@ViewController.swift#37 UIView:0x105376a60.height == 50.0>","<snapKit.LayoutConstraint:0x28127d0e0@ViewController.swift#38 UIView:0x105376a60.bottom == UITableViewCellContentView:0x105370a40.bottom - 10.0>","<NSLayoutConstraint:0x281554730 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x105370a40.height == 70.5 (active)>"
)
Will attempt to recover by breaking constraint
<snapKit.LayoutConstraint:0x28127d080@ViewController.swift#37 UIView:0x105376a60.height == 50.0>
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.