I have a category that adds the following method to UIView for this sort of thing:
- (NSArray *) allSubviews {
NSMutableArray *subviews = [self.subviews mutableCopy];
for (UIView *view in self.subviews) {
[subviews addObjectsFromArray: [view allSubviews]];
}
return subviews;
}
You can then NSLog() the returned array. Alternatively, for a little more detail, you could use the following:
- (NSString *) hierarchyToStringWithLevel: (int) level {
NSMutableString *results = [NSMutableString stringWithString: @"\n"];
for (int i = 0; i < level; i++) {
[results appendFormat: @"-\t"];
}
[results appendFormat: @"[%@, 0x%X], %@", [self class], self, NSStringFromCGRect(self.frame)];
for (UIView *child in self.subviews) {
[results appendFormat: @"%@", [child hierarchyToStringWithLevel: level + 1]];
}
return results;
}