Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need to inspect the view hierarchy on an iPhone program

Tags:

How do I determine what the view structure on my iPhone program while running on the simulator?

like image 430
Chris Avatar asked Feb 26 '10 16:02

Chris


People also ask

How do you view a hierarchy?

In the menu bar, select Window > Open Perspective, and then click Hierarchy View.

How do I inspect my iPhone app on my Mac?

On your iPad, iPhone or iPod, go to Settings > Safari > Advanced and toggle on Web Inspector . On your Mac, open Safari and go to Safari > Preferences > Advanced then check Show Develop menu in menu bar . Connect your iOS device to your Mac with the USB cable. On your Mac, restart Safari.

How do I debug UI in Xcode?

Go back to Xcode and click on the Debug View Hierarchy button in the Debug bar. Alternatively, go to Debug\View Debugging\Capture View Hierarchy. Xcode is now interrupting your app and handing the reigns to the debugger, just as if you had paused your app with the pause button on the Debug bar.


1 Answers

There's a built-in way to dump the view hierarchy: recursiveDescription

NSLog(@"%@", [view recursiveDescription]);

It will output something like this:

<UIView: 0x6a107c0; frame = (0 20; 320 460); autoresize = W+H; layer = […]    | <UIRoundedRectButton: 0x6a103e0; frame = (124 196; 72 37); opaque = NO; […]    |    | <UIButtonLabel: 0x6a117b0; frame = (19 8; 34 21); text = 'Test'; […] 

See: https://developer.apple.com/library/content/technotes/tn2239/_index.html

like image 134
marcprux Avatar answered Oct 27 '22 00:10

marcprux