Swift 无法同时满足约束-制图

Swift 无法同时满足约束-制图,swift,autolayout,Swift,Autolayout,我在我的应用程序中使用了AutoLayout,代码是用Swift 2.0编写的,它使用制图来帮助约束。 但是有什么东西阻止了我的应用程序,否则,我就用它以编程方式添加一个视图 func addButtonOne() -> Void { buttonOne = UIButton() buttonOne.backgroundColor = UIColor.greenColor() self.view.addSubview(buttonOne) constrai

我在我的应用程序中使用了AutoLayout,代码是用Swift 2.0编写的,它使用制图来帮助约束。 但是有什么东西阻止了我的应用程序,否则,我就用它以编程方式添加一个视图

func addButtonOne() -> Void {
    buttonOne = UIButton()
    buttonOne.backgroundColor = UIColor.greenColor()
    self.view.addSubview(buttonOne)

    constrain(buttonOne, view) { buttonOne, view in
        buttonOne.left == view.right - 12
        buttonOne.right == view.left + 12
        buttonOne.bottom == view.bottom - 12
    }

}
但在编译之后,会返回:

2015-09-23 00:54:24.489 Fun With Swift[24809:2358352] 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:0x7afe2160 H:[UIView:0x7afdfe90]-(-12)-[UIButton:0x7afe13b0](LTR)>",
"<NSLayoutConstraint:0x7afe2730 UIButton:0x7afe13b0.right == UIView:0x7afdfe90.left + 12>",
"<NSLayoutConstraint:0x7b0866e0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7afdfe90(320)]>"
)
2015-09-23 00:54:24.489 Swift的乐趣[24809:2358352]无法同时满足约束条件。
可能下面列表中至少有一个约束是您不想要的。
试试这个:
(1) 看看每一个约束,试着找出你不期望的;
(2) 找到添加了不需要的约束的代码,然后修复它。
(注意:如果您看到您不了解的NSAutoresizingMaskLayoutConstraints,
请参阅UIView属性translatesAutoresizingMaskIntoConstraints的文档
(
"",
"",
""
)

有人知道我能做什么吗?这是一个不同的问题,因为我使用了一个库。

添加约束代码应该如下所示

 constrain(buttonOne, view) { buttonOne, view in
            buttonOne.left == view.left + 12
            buttonOne.right == view.right - 12
            buttonOne.bottom == view.bottom - 12
        }

如果你需要底部有一个按钮,从左到右和底部留有12磅的边距,可能是编号的重复。我正在使用Swift和一个库来实现这一点。我不认为库是这里的问题。问题在于这两个关系buttone.left==view.right-12 buttone.right==view.left+12。buttonOnce left view.right和buttonOne.right和view.left如何关联?