How do I determine what the view structure on my iPhone program while running on the simulator?
In the menu bar, select Window > Open Perspective, and then click Hierarchy View.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With