Boon
Boon

Reputation: 41470

How to print view hierarchy of a specific view controller?

I issue the following call in the console and got the view hierarchy.

(lldb) expr -l objc++ -O -- [[[UIWindow keyWindow] rootViewController] _printHierarchy]

<TestViewController 0x13ee07360>, state: appeared, view: <TestView 0x13ed10520>
   | <MyApp.MenuController 0x13ee126b0>, state: disappeared, view:  (view not loaded)
   | <UINavigationController 0x13ee15b60>, state: appeared, view: <UILayoutContainerView 0x13ed16b80>
   |    | <MyApp.ViewController 0x13ee13b50>, state: appeared, view: <UIView 0x13ee1d700>

How do I print the view hierarchy for MyApp.ViewController? Can the address of the view controller be used somehow?

Upvotes: 1

Views: 1685

Answers (1)

Martin R
Martin R

Reputation: 539675

Just enter the lldb command

expr -l objc++ -O -- [0x13ee13b50 _printHierarchy]

where 0x13ee13b50 is the address of the view controller that you are interested in.

Upvotes: 4

Related Questions