View-Stack - counting how many views are in it

172 Views Asked by At

Is there a way to find out how many views are currently in the view-stack? Just curious to see how big its getting at any point when the code is pushing one view onto another...

1

There are 1 best solutions below

1
Todd Yandell On

You should be able to add your own support for counting subviews recursively using a category on UIView:

@implementation UIView (SubviewCount)

- (NSUInteger)subviewCount
{
   NSUInteger count = [[self subviews] count];
   for (UIView *view in [self subviews])
      count += [view subviewCount];
   return count;
}

@end