How do I inspect the view hierarchy in iOS?
Xcode 6 now has 3D view hierarchy inspection built in like Reveal App and Spark Inspector.
Click on the "Debug View Hierarchy" button while your app is running to pause execution and inspect the views at the current moment.
More info at Apple's documentation.
I need to inspect the view hierarchy on an iPhone program
Along the lines of what Yannick suggests, Erica Sadun has code here that pretty-prints the view hierarchy (with class and frame information). You can make this into a UIView category with the following interface:
@interface UIView (ExploreViews)
void doLog(int level, id formatstring,...)
for (i = 0; i < level; i++) printf(" ");
id outstring = [[NSString alloc] initWithFormat:formatstring arguments:arglist];
fprintf(stderr, "%s\n", [outstring UTF8String]);
@implementation UIView (ExploreViews)
doLog(level, @"%@", [[self class] description]);
doLog(level, @"%@", NSStringFromCGRect([self frame]));
for (UIView *subview in [self subviews])
[subview exploreViewAtLevel:(level + 1)];
How to find views in Debug View Hierarchy based on their address?
If you type (or copy/paste) the hex address into the search field at the bottom of the Navigator Pane, it should filter / find the object:
Is there a way to see object names in debug view hierarchy?
No, there is not (unfortunately).
The information is not maintained at runtime to my knowledge, so you also won't be able to use lldb from Xcode's console to figure it out.
Probably worth a feature request to Apple!
View Debugging: What are the layers of view in any View Controller?
The Xcode debugger provides the ability to inspect and understand the view hierarchy.
With your app running in the debugger, click the Debug View Hierarchy button in the debug bar.
Here is reference of visual code debugging.
Xcode Debug View Hierarchy finding viewcontroller
Update: Starting with Xcode 9, view controllers are listed right along the view hierarchy in the visual debugger.
You can get the memory address of the selected view from the inspector in Xcode and then use the console to get the view's view controller using
UIView implements this method by returning the UIViewController object
that manages it (if it has one) or its superview (if it doesn’t)
Uialertview Addsubview in Ios7
Ios: Convert Utc Nsdate to Local Timezone
Prevent Screen Capture in an iOS App
How to Intercept Touches Events on a Mkmapview or Uiwebview Objects
Converting Storyboard from Iphone to Ipad
How to Select Multiple Images from Uiimagepickercontroller
How to Record a Conversation/Phone Call on Ios
-Didselectrowatindexpath: Not Being Called
How to Change Uipickerview Height
Uiview Infinite 360 Degree Rotation Animation
How to Open Phone Settings When a Button Is Clicked
Swift: Reload a View Controller
How to Increment the Filename If File Already Exists