Debugging Autolayout

If you need to debug the constraints that produced any view layout, just hit LLVM, and type:

[cc lang=”objc”]
po [[UIWindow keyWindow] _autolayoutTrace]
[/cc]

This will help you get the Autolayout Trace. Pick up the troublesome view, find its memory address, and then try:

[cc lang=”objc”]
po [0x12341234 constraintsAffectingLayoutForAxis:1]
[/cc]

Note that you should replace 0x12341234 with the memory address of the view you’d like to debug. AxisX = 0, while AxisY = 1.

Props to this extremely useful post.

%d