Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I loop through all subviews of a UIView, and their subviews and their subviews

How can I loop through all subviews of a UIView, and their subviews and their subviews?

like image 795
123hal321 Avatar asked Apr 30 '10 17:04

123hal321


1 Answers

Use recursion:

// UIView+HierarchyLogging.h @interface UIView (ViewHierarchyLogging) - (void)logViewHierarchy; @end  // UIView+HierarchyLogging.m @implementation UIView (ViewHierarchyLogging) - (void)logViewHierarchy {     NSLog(@"%@", self);     for (UIView *subview in self.subviews)     {         [subview logViewHierarchy];     } } @end  // In your implementation [myView logViewHierarchy]; 
like image 135
Ole Begemann Avatar answered Sep 25 '22 18:09

Ole Begemann