Advertisement
Guest User

iPhone Log View Hierarchy

a guest
Apr 30th, 2010
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. +(void) logViewHeirachyOfView:(UIView *) aView{
  2.     NSString *indent=@"";
  3.     NSMutableArray *superViews=[NSMutableArray arrayWithCapacity:1];
  4.     //NSMutableArray *subViews=[NSMutableArray arrayWithCapacity:1];
  5.    
  6.     if (aView.superview) {
  7.         UIView *aSuperView=aView;
  8.         while (aSuperView.superview) {
  9.             [superViews insertObject:aSuperView.superview atIndex:0];
  10.             aSuperView=aSuperView.superview;
  11.         }
  12.     }
  13.  
  14.     for (UIView *eachView in superViews) {
  15.         NSLog(@"%@%@:%@",indent,[eachView class],NSStringFromCGRect(eachView.frame) );
  16.         indent=[indent stringByAppendingString:@"   "];
  17.     }
  18.     NSLog(@"%@%@:%@ <------- Sampled View",indent,[aView class],NSStringFromCGRect(aView.frame) );
  19.     if (aView.subviews) {
  20.         indent=[indent stringByAppendingString:@"   "];
  21.         for (UIView *eachView in aView.subviews) {
  22.             [DebugUIView logSubViewsOfView:eachView withIndent:indent];
  23.         }
  24.     }
  25.    
  26. }//------------------------------------logViewHeirachyOfView:------------------------------------
  27.  
  28.  
  29. +(void) logSubViewsOfView:(UIView *) aView withIndent:(NSString *) anIndent{
  30.     if (aView.subviews) {
  31.         NSString *indent=[anIndent stringByAppendingString:@"   "];
  32.         for (UIView *eachView in aView.subviews) {
  33.             NSLog(@"%@%@:%@",indent,[eachView class],NSStringFromCGRect(eachView.frame) );
  34.             if (eachView.subviews) {
  35.                 for (UIView *eachSubView in aView.subviews) {
  36.                     [DebugUIView logSubViewsOfView:eachSubView withIndent:indent];
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }//------------------------------------logSubViewsOfView:------------------------------------
  42.  
  43. +(void) logViewsForWindow:(UIWindow *) aWindow{
  44.     NSLog(@"%@:%@",[aWindow class],NSStringFromCGRect(aWindow.frame) );
  45.     if (aWindow.subviews) {
  46.         [DebugUIView logSubViewsOfView:aWindow withIndent:@""];
  47.     }
  48. }//------------------------------------logViewsForWindow:------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement