iOS递归打印UIView的结构
2014-02-24 09:52
627 查看
iOS递归打印UIView结构
1、iOS在lldb调试窗口可用recursiveDescription打印该UIView的整个结构,如下:
2、用Objective-C代码实现如下:
1、iOS在lldb调试窗口可用recursiveDescription打印该UIView的整个结构,如下:
2、用Objective-C代码实现如下:
+ (NSString *)showViewHierarchy:(UIView *)view level:(NSInteger)level { NSMutableString * description = [NSMutableString string]; NSMutableString * indent = [NSMutableString string]; for (NSInteger i = 0; i < level; i++) { [indent appendString:@" |"]; } [description appendFormat:@"\n%@%@", indent, [view description]]; for (UIView * item in view.subviews) { [description appendFormat:@"%@", [UIView showViewHierarchy:item level:level + 1]]; } return [description copy]; } // // 实现view的循环打印 - (NSString *)recursiveDiscription { return [UIView showViewHierarchy:self level:0]; }
相关文章推荐
- java分享第七天-03(递归打印文件目录的树状结构)
- jquery前端递归打印出树状结构的多层复杂map或json键值对数据
- ios 私有方法打印出任意视图的视图层次结构
- iOS-获取UIView的所有层级结构
- 纯代码搭建iOS三级结构(UITabbarController+UINavigationController+UIViewController)
- 数据结构之递归打印实数
- ios 命令行打印视图结构命令
- 使用递归打印出一个文件夹下所有子孙文件的树形结构
- 在iOS中获取UIView的所有层级结构 相关
- iOS:二叉树多级表格的使用,使用三方库TreeTableView-master实现对json解析数据的递归遍历整理成树状结构
- 打印iOS UI结构
- 使用java的File类遍历文件夹,打印树状结构(递归实现)
- ios,递归打印一个view的子view
- java_递归遍历文件目录结构,打印所有的目录名和文件名
- ios入门攻略 07篇 C语言基础【循环结构之for语句,打印九九乘法表】
- iOS 打印 UI结构
- 利用一个简单的递归实现打印目录的层次结构
- ios UIView父子关系和层次结构
- iOS-获取UIView的全部层级结构
- iOS开发--打印NSRange,CGRect等结构体