zoukankan      html  css  js  c++  java
  • 查看UIWindows的视图层次

    忘记从哪里看到的这个了,不过非常有用,记录下来!

    // 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: aView atIndent:0 into:outstring];

    return [outstring autorelease];

    }

    // Show the tree

    - (void)logViewTreeForMainWindow

    {

        NSLog(@"The view tree: %@", [self displayViews:self.window]);

    }

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

  • 相关阅读:
    spring事务
    事务理解
    zookeeper总结
    maven项目怎样将本地jar包打进去
    applicationcontext理解使用
    servlet 中getLastModified()
    Findbug插件静态java代码扫描工具使用
    上行短信/下行短信
    zookeeper基本原理
    git分支的合并
  • 原文地址:https://www.cnblogs.com/nanoCramer/p/3199347.html
Copyright © 2011-2022 走看看