iOS开发 快速定位约束冲突位置

开发过程中遇到约束冲突的报错:

2021-01-23 15:35:00.036312+0800 WisdomChain[1057:512850] [LayoutConstraints] 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. 
(
    "<NSLayoutConstraint:0x283c4c910 UIView:0x111e168f0.width == - 16   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x283c4c910 UIView:0x111e168f0.width == - 16   (active)>

1.先点击Debug View Hierarchy

Debug View Hierarchy

2.打印页控件层级和地址

Obj-C project

po [[UIWindow keyWindow] _autolayoutTrace]

Swift project

expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]

3.搜索报错的地址0x111e168f0,定位到错误控件

image.png

断点小技巧:

image.png
image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容