ios - 如何调试自动布局约束?

标签 ios swift debugging autolayout constraints

我是 iOS 开发新手。每当我运行我的应用程序时,我都会收到此冲突约束错误。您能给我一些关于如何调试此问题的建议吗?

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.

最佳答案

似乎您添加了一个约束,而另一个约束正在抵消该约束。

通常,如果您右键单击,您就可以获得“建议的约束”,尝试使用它们,看看它是否有效!

编辑: enter image description here

关于ios - 如何调试自动布局约束?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38361346/

相关文章:

ios - 如何调整标签大小以根据屏幕大小更改

iphone - UINavigationItem 居中标题

ios - 无法在 Swift 中强制将类型 'Void' 转换为 'String'

java - 检查 Eclipse 调试器中的当前异常?

iphone - iOS解析: string is null

python - Appium 在 iOS(真实设备)上访问 URL 会遇到 "(' Connection aborted .', BadStatusLine("''",))"

ios - iOS通过GEOpoint和Corelocation解析上传用户的位置

ios - Swift - 在重复循环中使用闭包

ios - iAd Banner swift,添加 iAd 后游戏开始崩溃

eclipse - 在 Eclipse 上调试时如何实时观察变量?