2016-07-13 72 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

我认为它有效,但我并不真正了解问题所在。无论如何,我们可以找出真正的问题是什么? –