Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.49 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Iterate over all subviews of a specific type
  2. @implementation Util
  3.  
  4. + (void)iterateOverSubviewsOfType:(Class)viewType
  5.                    view:(UIView*)view
  6.                    blockToExecute:(void (^)(id subview))block
  7. {
  8.     for (UIView* subview in view.subviews) {
  9.         if ([subview isKindOfClass:viewType]) {
  10.             block(subview);
  11.         }
  12.     }
  13. }
  14.  
  15. @end
  16.        
  17. for (id subview in view.subviews) {
  18.         if ([subview isMemberOfClass:viewType]) {
  19.             block(subview);
  20.         }
  21.     }