iOS

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

2021-01-23  本文已影响0人  jzhang

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

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
上一篇 下一篇

猜你喜欢

热点阅读