“I’m just walking my beat friend. Mexico is my beat and I’m walking it…” (Johnny Depp / Once Upon a Time in Mexico)
In our case, UIViews are our beat, and we spend a lot of time walking them.
Here’s a simple function to recursively display all subviews within a parent view. It’s very convenient for finding out how many views are hidden within a parent view (such as UIImageViews, UILabels, UIButtons, etc.) — and it’s especially useful when debugging iPad apps with multiple levels of interactivity (such as scrollviews within scrollviews, or accordions within panels within scrollviews)…
- (void) dumpViews:(UIView *)theView withLevel:(int)theLevel { // this displays all views in the log // example usage: // NSLog (@"\r===================================\r===================================\r===================================\r"); // [self dumpViews:self.view withLevel:0]; for (int i = 0; i < [[theView subviews] count]; i++) { NSString *padding = @""; for (int n = 0; n < theLevel; n++) { padding = [NSString stringWithFormat:@"%@ ", padding]; } if (theLevel) padding = [NSString stringWithFormat:@"%@-", padding]; NSLog (@"%@%i : %@", padding, theLevel, [[[theView subviews] objectAtIndex:i] description]); [self dumpViews:[[theView subviews] objectAtIndex:i] withLevel:theLevel + 1]; } }
Jeff, we are going to host a DEO at TechWildcatters on 3/26. Hope you will be able to join!