[self logViewTreeForMainWindow];
// 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] %@\n", 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
{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
NSMutableString *outstring = [[NSMutableString alloc] init];
[self dumpView: window atIndent:0 into:outstring];
return outstring;
}
// Show the tree
- (void)logViewTreeForMainWindow
{
// CFShow([self displayViews: self.window]);
UIWindow *window = [UIApplication sharedApplication].keyWindow;
NSLog(@"The view tree:\n%@", [self displayViews: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
原创
©著作权归作者所有:来自51CTO博客作者mb646b2b3c1359c的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:git初体验(五)SSH的理解
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
驱动的层次结构
驱动的层次结构1.在Windows系统中,与一结构Device Object,用于记录与设备相关的信息。5.功能驱动创
数据结构 object windows 驱动程序 Windows -
进程的层次结构
windows不存在进程层次结构 所有进程相同地位 获得进程的句柄 unix 父子孙 进程家族 进程不能拒绝其子进程呢个的继承权
句柄 层次结构 子进程 unix 知识 -
centos7 挂在新硬盘给home
1.分区分区工具fdisk用法介绍 fdisk命令参数介绍 p、打印分区表。 n、新建一个新分区。 d、删除一个分区。 q、退出不保存。 w、把分区写进分区表,保存并退出首先使用fdisk -l 查看系统中的所有硬盘和分区信息。我们可以看出sdb是我新添加
centos7 挂在新硬盘给home CentOS 磁盘分区 增加磁盘 挂载