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 = ; 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的更多相关文章
- iOS - UIView
前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UIView : UIResponder <NSCoding, UIAppearance, UIAppeara ...
- iOS开发——UI篇OC篇&UIView/UIWindow/UIScreen/CALayer
UIView/UIWindow/UIScreen/CALayer 1.UIScreen可以获取设备屏幕的大小. 1 2 3 4 5 6 7 // 整个屏幕的大小 {{0, 0}, {320, 480} ...
- UIView的作用
UIView [UIView的作用] 主要用来显示应用程序的内容,可以作为label.button等控件的容器.表示屏幕上的一块矩形区域,同时可以处理该区域的绘制和触屏事件. MVC,MVVM等设计架 ...
- UIWindow与UIView
UIView与UIWindow * 一般应用程序只有一个UIWindow对象.所有的控件都是在UIWindow上展现的.每个UIView对象都有一个window属性,表示当前view显示在哪个窗体上. ...
- ios开发学习笔记(这里一定有你想要的东西,全部免费)
1,Search Bar 怎样去掉背景的颜色(storyboard里只能设置background颜色,可是发现clear Color无法使用). 其实在代码里还是可以设置的,那就是删除背景view [ ...
- iOS 开发笔记
1,Search Bar 怎样去掉背景的颜色(storyboard里只能设置background颜色,可是发现clear Color无法使用) 2,NSDate使用 3,UTTabviewCell 未 ...
- iOS项目开发知识点
前言部分 注:本文并非绝对原创 大部分内容摘自 http://blog.csdn.net/hengshujiyi/article/details/20943045 文中有些方法可能已过时并不适用于现在 ...
- iPhone与iPad开发实战读书笔记
iPhone开发一些读书笔记 手机应用分类1.教育工具2.生活工具3.社交应用4.定位工具5.游戏6.报纸和杂志的阅读器7.移动办公应用8.财经工具9.手机购物应用10.风景区相关应用11.旅游相关的 ...
- iOS项目开发中的知识点与问题收集整理①(Part 一)
前言部分 注:本文并非绝对原创 大部分内容摘自 http://blog.csdn.net/hengshujiyi/article/details/20943045 文中有些方法可能已过时并不适用于现在 ...
随机推荐
- table下tbody滚动条与thead对齐的方法且每一列可以不均等
1 前言 table下tbody滚动条与thead对齐的方法,开始在tbody的td和thead的tr>td,对每一个Item加入百分比,结果是没对齐.也尝试了用bootstrap的col-md ...
- Go语言规格说明书 之 结构体类型(Struct types)
go version go1.11 windows/amd64 本文为阅读Go语言中文官网的规则说明书(https://golang.google.cn/ref/spec)而做的笔记,介绍Go语言的 ...
- vue 安装教程(自己安装过程及遇到的一些坑)
1.安装node.js(http://www.runoob.com/nodejs/nodejs-install-setup.html) 2.基于node.js,利用淘宝npm镜像安装相关依赖 在cmd ...
- C#中Convert.ToInt32、int.TryParse、(int)和int.Parse四者的区别
Convert.ToInt32.(int)和int.Parse三者的区别: 首先:Convert.ToInt32 适合将object类类型转换成int类型,如Convert.ToInt32(sessi ...
- 目标检测-yolo
论文下载:http://arxiv.org/abs/1506.02640 代码下载:https://github.com/pjreddie/darknet 1.创新点 端到端训练及推断 + 改革区域建 ...
- python 全栈开发,Day126(创业故事,软件部需求,内容采集,显示内容图文列表,MongoDB数据导入导出JSON)
作业讲解 下载代码: HBuilder APP和flask后端登录 链接:https://pan.baidu.com/s/1eBwd1sVXTNLdHwKRM2-ytg 密码:4pcw 如何打开APP ...
- python 全栈开发,Day79(Django的用户认证组件,分页器)
一.Django的用户认证组件 用户认证 auth模块 在进行用户登陆验证的时候,如果是自己写代码,就必须要先查询数据库,看用户输入的用户名是否存在于数据库中: 如果用户存在于数据库中,然后再验证用户 ...
- WinAFL
winafl 标签(空格分隔): fuzz 构成 afl-fuzz.c 主模块 读取文件 维护testcase queue 进行mutate fuzz_one 评估代码覆盖率 执行遗传算法 更新界面 ...
- 搬家通知博文地址(将博客搬到CSDN)
(为了确认是您本人在申请搬家,请在原博客发表一 篇标题为<将博客搬至CSDN>的文章,并将文章地址填写在上方的"搬家通知博文地址"中.)
- kafka 数据存储结构+原理+基本操作命令
数据存储结构: Kafka中的Message是以topic为基本单位组织的,不同的topic之间是相互独立的.每个topic又可以分成几个不同的partition(每个topic有几个partitio ...