zoukankan      html  css  js  c++  java
  • UIView的层次结构–code

    转:http://blog.dongliwei.cn/archives/uiview-tree-code

    // Recursively travel down the view tree, increasing the indentation level for children
    
    - (void)dumpView:(UIView *)aView atIndent:(int)indent into:(NSMutableString *)outstring
    
    {
    
    for (int i = 0; i < indent; i++) [outstring appendString:@"--"];
    
    [outstring appendFormat:@"[%2d] %@
    ", indent, [[aView class] description]];
    
    for (UIView *view in [aView subviews])
    
    [self dumpView:view atIndent:indent + 1 into:outstring];
    
    }
    
    // Start the tree recursion at level 0 with the root view
    
    - (NSString *) displayViews: (UIView *) aView
    
    {
    
    NSMutableString *outstring = [[NSMutableString alloc] init];
    
    [self dumpView: self.window atIndent:0 into:outstring];
    
    return [outstring autorelease];
    
    }
    
    // Show the tree
    
    - (void)logViewTreeForMainWindow
    
    {
    
    //  CFShow([self displayViews: self.window]);
    
    ATLogInfo(@"The view tree:
    %@", [self displayViews:self.window]);
    
    }

    具体用法就是在你想知道你的view的层次的时候,调用一下这个logViewTreeForMainWindow函数就可以了。

    比方说:下面这个就是我的打印结果。非常清晰明了!

    [ 0] UIWindow

    –[ 1] UILayoutContainerView

    —-[ 2] UINavigationTransitionView

    ——[ 3] UIViewControllerWrapperView

    ——–[ 4] UIView                 —–rootViewController

    ———-[ 5] UITableView

    ————[ 6] ServerViewCell_iphone

    ————–[ 7] UITableViewCellContentView

    ————[ 6] ServerViewCell_iphone

    ————–[ 7] UITableViewCellContentView

    —-[ 2] UINavigationBar

    ——[ 3] UINavigationBarBackground

    ——[ 3] UILabel

    ——[ 3] UIButton

    ——–[ 4] UIImageView

    ——–[ 4] UIImageView

    –[ 1] UIView                  —-backView

    –[ 1] UITransitionView

    —-[ 2] UIView                —-CameraPlayerView.

    ——[ 3] UIView              for zoom.–frameView.

    ——–[ 4] UIImageView

    ——[ 3] UIImageView

    ——[ 3] UILabel

    ——–[ 4] UIImageView

    ——[ 3] UIImageView

    ——[ 3] UINavigationBar

    ——–[ 4] UINavigationBarBackground

    ——–[ 4] UINavigationItemView

    —-[ 2] UILayoutContainerView

    ——[ 3] UINavigationTransitionView   —–recordVideoView

    ——–[ 4] UIViewControllerWrapperView

    ———-[ 5] UIView

    ————[ 6] UITableView

    ————–[ 7] UIImageView

    ————–[ 7] UIImageView

    ————[ 6] UIToolbar

    ————–[ 7] _UIToolbarBackground

    ————–[ 7] UISegmentedControl

    ——[ 3] UINavigationBar

    ——–[ 4] UINavigationBarBackground

    ——–[ 4] UILabel

    ——–[ 4] UIButton

    ———-[ 5] UIImageView

    ———-[ 5] UIButtonLabel

  • 相关阅读:
    NET打包時加入卸载功能
    c#水晶报表注册码
    sqlserver:某年份某月份 是否在某时间段内的函数
    修改KindEditor编辑器 版本3.5.1
    Flash大文件上传(带进度条)
    让.Net程序脱离.net framework框架运行的方法(转载)
    夏天到了,什么时候园子的T恤可以出来?
    VS2005项目的安装与布署
    解决Select覆盖Div的简单直接的方法
    .Net向Page和UpdatePanel输出JS
  • 原文地址:https://www.cnblogs.com/ygm900/p/4573520.html
Copyright © 2011-2022 走看看