0
我使用AutoLayout和我的應用程序中使用Swift 2.0編寫的代碼並使用Cartograph來幫助約束。 但是,有東西阻止我的應用程序,否則,我用它來以編程方式添加視圖。無法同時滿足約束條件 - 製圖
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)]>"
)
任何人都知道我能做些什麼?這是一個不同的問題,因爲我使用了一個庫。
可能重複:什麼創造了約束名爲UIView-Encapsulated-Layout-Width&Height?](http://stackoverflow.com/questions/23308400/auto-layout-what-creates-constraints-named-uiview-encapsulated-layout-width-h) – jtbandes
我使用Swift和一個庫來做到這一點。 –
我不認爲圖書館是這裏的問題。 – jtbandes