Last Updated: February 25, 2016
·
834
· nalitzis

iOS view hierarchy

Sometimes it is usefeul to find the view hierarchy of a certain graphical component.
On iOS, here's a small code snippet to do this:

- (void) printViews:(UIView *)view marker:(NSString *)s{
    for(UIView *v in view.subviews){
        NSString *s2 = [s stringByAppendingString:@"*"];
        NSLog(@"%@ %@", s2, v);
        [self printViews:v marker:s2];
    }
}