2016-07-13 73 views
0

我是iOS開發新手。每當我運行我的應用程序,我都會得到這個衝突的約束錯誤。你能告訴我一些關於如何調試這個問題的東西嗎?如何調試AutoLayout約束?

2016-07-13 12:53:51.186 Calculator[4458:50017] 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. 
(
    "<_UILayoutSupportConstraint:0x7fcaf3c5e670 V:[_UILayoutGuide:0x7fcaf3c62a80(0)]>", 
    "<_UILayoutSupportConstraint:0x7fcaf3c5c060 _UILayoutGuide:0x7fcaf3c62a80.bottom == UIView:0x7fcaf3c54390.bottom>", 
    "<NSLayoutConstraint:0x7fcaf3c54b00 UIImageView:0x7fcaf3c54c70.width == UIImageView:0x7fcaf3c54c70.height>", 
    "<NSLayoutConstraint:0x7fcaf3c633d0 V:|-(0)-[UIImageView:0x7fcaf3c54c70] (Names: '|':UIView:0x7fcaf3c54390)>", 
    "<NSLayoutConstraint:0x7fcaf3c63420 H:[UIImageView:0x7fcaf3c54c70]-(0)-| (Names: '|':UIView:0x7fcaf3c54390)>", 
    "<NSLayoutConstraint:0x7fcaf3c63470 H:|-(0)-[UIImageView:0x7fcaf3c54c70] (Names: '|':UIView:0x7fcaf3c54390)>", 
    "<NSLayoutConstraint:0x7fcaf3c63560 V:[UIImageView:0x7fcaf3c54c70]-(0)-[_UILayoutGuide:0x7fcaf3c62a80]>", 
    "<NSLayoutConstraint:0x7fcaf3c67e50 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fcaf3c54390(736)]>", 
    "<NSLayoutConstraint:0x7fcaf3c61230 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7fcaf3c54390(414)]>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fcaf3c54b00 UIImageView:0x7fcaf3c54c70.width == UIImageView:0x7fcaf3c54c70.height> 

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. 
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 
+0

你可以看到一個Xcode中必須打破:'' 意味着約束,這是'的ImageView .width = imageView.height'打破了 – penatheboss

+1

我可以問你想達到什麼嗎?你想有一個UIImageView而不是一個UIView和UIView有高= 736和寬= 414?約束會中斷,因爲您不能將UIImageView的寬度與高度相等並匹配UIView的邊緣。如果你能澄清,我很高興發表一個例子。 – JingJingTao

回答

0

看起來好像你有一個約束被添加,正在被另一個約束反作用。

通常情況下,如果你右鍵點擊,你可以得到'建議約束'嘗試使用它們,看看它是否工作!

編輯: enter image description here

+0

感謝您的及時迴應。我應該在哪裏點擊右鍵? –

+0

請檢查我的編輯!我添加了一張照片給你,看看 – Konsy

+0

我認爲它有效,但我並不真正瞭解問題所在。無論如何,我們可以找出真正的問題是什麼? –