How do I inspect the view hierarchy in iOS?

I don’t know if there is a GUI view inspection tool, but I have had some luck with the debugging method on UIView: -recursiveDescription

if you pause the program in the debugger and input this into GDB (Edit: also works in LLDB)

po [[UIWindow keyWindow] recursiveDescription]

You get a printout of your entire view hierarchy. You can also call it on a specific view to get a printout of the view hierarchy of that view.

It can be a little tedious to wade through the info you get out of it, but it has proved useful to me.

Credit goes to this blog post which talked about this method and also linked to this helpful, but rather hard to find Apple tech note.

Leave a Comment