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函数就可以了。

  • 相关阅读:
    elastalert邮件告警
    Kubernetes(k8s)集群安装
    supervisord进程管理
    Flask Ansible自动化平台搭建(持续更新)
    pandas数据导出Execl
    docker运行dubbo-admin
    Activemq集群搭建
    Zabbix自动发现java进程
    selenium爬取百度图片
    Beta 冲刺(1/7)
  • 原文地址:https://www.cnblogs.com/nanoCramer/p/3199347.html
Copyright © 2011-2022 走看看