UIView-Encapsulated-Layout-Width和LayoutConstraint

时间:2019-06-15 14:49:36

标签: swift

运行应用程序时出现以下错误。我有什么样的视觉问题?

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-06-15 17:45:15.916490+0300 ...[3888:779219] [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:0x280cf51a0@MainTableViewController.swift#3209 ....DeviceTableViewCell:0x10c82cc00.width == 375.0>",
    "<NSLayoutConstraint:0x280be41e0 'UIView-Encapsulated-Layout-Width' ....DeviceTableViewCell:0x10c82cc00'cellId'.width == 0   (active)>"
)

Will attempt to recover by breaking constraint 
<SnapKit.LayoutConstraint:0x280cf51a0@MainTableViewController.swift#3209 ...DeviceTableViewCell:0x10c82cc00.width == 375.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.

 cell.snp.makeConstraints { (make) in
            make.top.equalTo(100)
            make.height.equalTo(205)
            make.width.equalTo(view.frame.width)
        }

1 个答案:

答案 0 :(得分:0)

我认为您对特定的cell有2个宽度限制,所以请检查一下。

  • 转到情节提要。
  • 打开右侧菜单。
  • 在顶部单击尺寸检查器,并检查您的约束。

enter image description here

或者尝试更改宽度限制的优先级。

make.width.equalTo(view.frame.width).priority(999)