一个Autolayout的调试技巧
当视图的Autolayout出现问题的时候,可以在Xcode添加一个UIViewAlertForUnsatisfiableConstraints
symbolic断点,如果是Obj-C项目,那么就添加po [[UIWindow keyWindow] _autolayoutTrace]
,如果是Swift项目就添加expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]
.
现在控制台就会打印ambiguous
的信息:
UIWindow:0x7f9481c93360
| •UIView:0x7f9481c9d680
| | *UIView:0x7f9481c9d990- AMBIGUOUS LAYOUT for UIView:0x7f9481c9d990.minX{id: 13}, UIView:0x7f9481c9d990.minY{id: 16}
| | *_UILayoutGuide:0x7f9481c9e160- AMBIGUOUS LAYOUT for _UILayoutGuide:0x7f9481c9e160.minY{id: 17}
| | *_UILayoutGuide:0x7f9481c9ebb0- AMBIGUOUS LAYOUT for _UILayoutGuide:0x7f9481c9ebb0.minY{id: 27}
网友评论