Snapkit无法同时满足约束make.edges.equalToSuperview()

时间:2019-02-04 10:37:03

标签: ios swift autolayout snapkit

每当我在容器视图内将边缘限制为stackview的超级视图时,调试器就会不断抱怨。

代码

lazy var containerView: View = {
    let view = View()
    view.backgroundColor = .clear
    self.addSubview(view)
    view.snp.makeConstraints({ (make) in
        make.edges.equalToSuperview() //warnig here l19
    })
    return view
}()

lazy var stackView: StackView = {
    let subviews: [UIView] = []
    let view = StackView(arrangedSubviews: subviews)
    view.alignment = .leading
    self.containerView.addSubview(view)
    view.snp.makeConstraints({ (make) in
        make.edges.equalToSuperview().inset(inset)  //warnig here L30
    })
    return view
}()


[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:0x281fbefa0@ProductModelCell.swift#19 X_Debug.View:0x109c7c500.left == X_Debug.ProductVariantsCellItem:0x1041e7e00.left>",
    "<SnapKit.LayoutConstraint:0x281fbf240@ProductModelCell.swift#19 X_Debug.View:0x109c7c500.right == X_Debug.ProductVariantsCellItem:0x1041e7e00.right>",
    "<SnapKit.LayoutConstraint:0x281fbb9c0@ProductModelCell.swift#30 X_Debug.StackView:0x109c7c300.left == X_Debug.View:0x109c7c500.left + 10.0>",
    "<SnapKit.LayoutConstraint:0x281fbbcc0@ProductModelCell.swift#30 X_Debug.StackView:0x109c7c300.right == X_Debug.View:0x109c7c500.right - 10.0>",

0 个答案:

没有答案