转: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 = ; i < indent; i++) [outstring appendString:@"--"];

[outstring appendFormat:@"[%2d] %@\n", indent, [[aView class] description]];

for (UIView *view in [aView subviews])

[self dumpView:view atIndent:indent +  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: into:outstring];

return [outstring autorelease];

}

// Show the tree

- (void)logViewTreeForMainWindow

{

//  CFShow([self displayViews: self.window]);

ATLogInfo(@"The view tree:\n%@", [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

UIView的层次结构–code的更多相关文章

  1. iOS - UIView

    前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UIView : UIResponder <NSCoding, UIAppearance, UIAppeara ...

  2. iOS开发——UI篇OC篇&UIView/UIWindow/UIScreen/CALayer

    UIView/UIWindow/UIScreen/CALayer 1.UIScreen可以获取设备屏幕的大小. 1 2 3 4 5 6 7 // 整个屏幕的大小 {{0, 0}, {320, 480} ...

  3. UIView的作用

    UIView [UIView的作用] 主要用来显示应用程序的内容,可以作为label.button等控件的容器.表示屏幕上的一块矩形区域,同时可以处理该区域的绘制和触屏事件. MVC,MVVM等设计架 ...

  4. UIWindow与UIView

    UIView与UIWindow * 一般应用程序只有一个UIWindow对象.所有的控件都是在UIWindow上展现的.每个UIView对象都有一个window属性,表示当前view显示在哪个窗体上. ...

  5. ios开发学习笔记(这里一定有你想要的东西,全部免费)

    1,Search Bar 怎样去掉背景的颜色(storyboard里只能设置background颜色,可是发现clear Color无法使用). 其实在代码里还是可以设置的,那就是删除背景view [ ...

  6. iOS 开发笔记

    1,Search Bar 怎样去掉背景的颜色(storyboard里只能设置background颜色,可是发现clear Color无法使用) 2,NSDate使用 3,UTTabviewCell 未 ...

  7. iOS项目开发知识点

    前言部分 注:本文并非绝对原创 大部分内容摘自 http://blog.csdn.net/hengshujiyi/article/details/20943045 文中有些方法可能已过时并不适用于现在 ...

  8. iPhone与iPad开发实战读书笔记

    iPhone开发一些读书笔记 手机应用分类1.教育工具2.生活工具3.社交应用4.定位工具5.游戏6.报纸和杂志的阅读器7.移动办公应用8.财经工具9.手机购物应用10.风景区相关应用11.旅游相关的 ...

  9. iOS项目开发中的知识点与问题收集整理①(Part 一)

    前言部分 注:本文并非绝对原创 大部分内容摘自 http://blog.csdn.net/hengshujiyi/article/details/20943045 文中有些方法可能已过时并不适用于现在 ...

随机推荐

  1. 瞅瞅!!免费看VIP视频的技巧

    最近再逛强大的知乎,发现一个免费看VIP视频的方法(腾讯是可能有点不稳定) 以爱奇艺为例: 复制URL到www.a6a6.org 把地址输入到输入框,点击开始 然后会提示你输入提取码 输入:22336 ...

  2. npm install 报错(npm ERR! errno -4048,Error: EPERM: operation not permitted,)解决方法

    npm ERR! path E:\SouthernPowerGridProject\web_project\AutoOPS\autoops\node_modules\fsevents\node_mod ...

  3. 父窗口中获取iframe中的元素

    js 在父窗口中获取iframe中的元素 1. 格式:window.frames["iframe的name值"].document.getElementById("ifr ...

  4. 【ES】学习3-请求体查询

    1.空查询 GET /index_2014*/type1,type2/_search {} GET /_search { , } 2.查询表达式 DSL只需将查询语句传递给 query 参数 GET ...

  5. 性能测试三十四:jvm内存结构(栈、堆、永久代)

    Java内存管理机制 Java采用了自动管理内存的方式Java程序是运行在Jvm之中的Java的跨平台的基于Jvm的跨平台特性内存的分配和对象的创建是在Jvm中用户可以通过一系列参数来配置Jvm Jv ...

  6. python接口自动化测试二十九:yaml配置文件的写和读

    # 先安装ruamel.yaml模块 写入配置文件: import os# 先安装ruamel.yaml模块from ruamel import yaml # 将字典写入到yamldict = { ' ...

  7. BOM下的属性和方法---上

    -------------BOM------------------------------------------------ 三个系统对话框   浏览器可以通过alert().confirm()和 ...

  8. nginx部署网站

    部署单个网站非常简单,只要将网站HTML文件和资源文件(.jpg .css .js等)全部复制到nginx-1.13.12\html目录下. 然后启动 启动进入cmd,切换到nginx-1.13.12 ...

  9. oracle中计算某月的天数

    select add_months(to_date('201202', 'YYYYMM'),1)-to_date('201202', 'YYYYMM') from dual

  10. Angular2学习(一)

    Angular2的新特性: angular2的核心: 模块.组件.元数据.模板.数据绑定.服务.指令.依赖注入.模块. 组件:层层嵌套,形成组件树.父子组件沟通有输入和输出接口 组件包含JavaScr ...