打印ViewTree
来源:互联网 发布:json美化 js 编辑:程序博客网 时间:2024/06/06 05:15
查看当前viewtree结构
下列代码加入到AppDelegate
- (void)dumpView:(UIView *)aView atIndent:(int)indentinto:(NSMutableString *)outstring
{
for (int i = 0; i< indent; i++) [outstring appendString:@"--"];
[outstringappendFormat:@"[%2d] %@\n", indent, [[aView class] description]];
for (UIView *viewin [aView subviews])
[selfdumpView: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:self.window atIndent:0 into:outstring];
return outstring ;
}
// Show the tree
- (void)logViewTreeForMainWindow
{
// CFShow([self displayViews: self.window]);
NSLog(@"Theview tree:\n%@", [self displayViews:self.window]);
}
然后在你想使用的地方使用
AppDelegate*a=(AppDelegate *)[[UIApplicationsharedApplication] delegate];
[alogViewTreeForMainWindow];
此时打印的就是 当前的viewtree
如下:
[ 0] UIWindow
--[ 1] UILayoutContainerView
----[ 2] UITransitionView
------[ 3] UIViewControllerWrapperView
--------[ 4] UILayoutContainerView
----------[ 5] UINavigationTransitionView
------------[ 6] UIViewControllerWrapperView
--------------[ 7] UITableView
----------------[ 8] UITableViewCell
------------------[ 9] UITableViewCellContentView
--------------------[10] UILabel
--------------------[10] UIImageView
------------------[ 9] UIButton
--------------------[10] UIImageView
------------------[ 9] UIView
----------------[ 8] UITableViewCell
------------------[ 9] UITableViewCellContentView
--------------------[10] UILabel
--------------------[10] UIImageView
------------------[ 9] UIButton
--------------------[10] UIImageView
------------------[ 9] UIView
----------------[ 8] UITableViewCell
------------------[ 9] UITableViewCellContentView
--------------------[10] UILabel
--------------------[10] UIImageView
------------------[ 9] UIButton
--------------------[10] UIImageView
------------------[ 9] UIView
----------------[ 8] UITableViewCell
------------------[ 9] UITableViewCellContentView
--------------------[10] UILabel
--------------------[10] UIImageView
------------------[ 9] UIButton
--------------------[10] UIImageView
------------------[ 9] UIView
----------------[ 8] UITableViewCell
------------------[ 9] UITableViewCellContentView
--------------------[10] UILabel
--------------------[10] UIImageView
------------------[ 9] UIButton
--------------------[10] UIImageView
------------------[ 9] UIView
----------------[ 8] UITableViewCell
------------------[ 9] UITableViewCellContentView
--------------------[10] UILabel
--------------------[10] UIImageView
------------------[ 9] UIButton
--------------------[10] UIImageView
------------------[ 9] UIView
----------------[ 8] _UITableViewSeparatorView
----------------[ 8] _UITableViewSeparatorView
----------------[ 8] _UITableViewSeparatorView
----------------[ 8] _UITableViewSeparatorView
----------------[ 8] _UITableViewSeparatorView
----------------[ 8] _UITableViewSeparatorView
----------------[ 8] _UITableViewSeparatorView
----------[ 5] UINavigationBar
------------[ 6] UIMoreListController
------------[ 6] UINavigationItemView
------------[ 6] UINavigationButton
--------------[ 7] UIImageView
--------------[ 7] UIButtonLabel
----[ 2] UITabBarCustomizeView
------[ 3] UINavigationBar
--------[ 4] UINavigationBarBackground
--------[ 4] UINavigationItemView
--------[ 4] UINavigationButton
----------[ 5] UIImageView
----------[ 5] UIButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
----[ 2] UITabBar
------[ 3] _UITabBarBackgroundView
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
------[ 3] UITabBarButton
--------[ 4] UITabBarSelectionIndicatorView
--------[ 4] UITabBarSwappableImageView
--------[ 4] UITabBarButtonLabel
- 打印ViewTree
- viewTree
- Android ViewTree and DecorView
- ViewTreeObserver类监听ViewTree
- Android ViewTree and DecorView
- Android图形用户界面开发之ViewTree和DecorView详细介绍
- c#操作通过button控制viewtree节点的改变
- Android图形用户界面开发之ViewTree和DecorView详细介绍
- Android图形用户界面开发之ViewTree和DecorView详细介绍
- Android图形用户界面开发之ViewTree和DecorView详细介绍
- Android图形用户界面开发之ViewTree和DecorView详细介绍
- Android GUI系统-ViewTree的创建(二)
- Android GUI系统-ViewTree的管理者(三)
- Android GUI系统-ViewTree的遍历(四)
- android 的View Tree和 DecorView(Android ViewTree and DecorView)
- App的启动过程(5)ViewTree遍历中最后一步的Draw
- 打印
- 打印
- 用马克飞象+ 印象笔记 快速方便写技术博客方法
- DM647+seed-XD560PLUS配置
- 左式堆
- 计算机专业的毕业设计题目大全
- UITabBarController显示多于5个标签时的如何直接显示视图而非More处理方式
- 打印ViewTree
- 《谁的大学不迷茫》
- 关闭内嵌webbrowser控件跳转时声音以及鼠标沙漏状态
- Windows下PHP开发环境搭建(PHP+Apache+MySQL)
- C++ primer plus 六七章总结
- C++ primer plus 八九章总结
- <!DOCTYPE> 标签的那些事
- LeetCode 149. Max Points on a Line
- 败者树