码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 打印出视图中所有的子视图的名称

时间:2014-10-11 00:46:44      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:http   io   os   使用   ar   for   2014   on   cti   

使用递归:

- (void)listSubviewsOfView:(UIView *)view {

    // Get the subviews of the view
    NSArray *subviews = [view subviews];

    // Return if there are no subviews
    if ([subviews count] == 0) return; // COUNT CHECK LINE

    for (UIView *subview in subviews) {

        // Do what you want to do with the subview
        NSLog(@"%@", subview);

        // List the subviews of subview
        [self listSubviewsOfView:subview];
    }
}

方法转载自:http://stackoverflow.com/a/7244069/3458781

打印结果:

2014-10-10 16:05:14.191 MyAPP[1951:60b] <UIView: 0x16d61a90; frame = (0 64; 320 31); autoresize = RM+BM; layer = <CALayer: 0x16ddb850>>
2014-10-10 16:05:14.192 Vinyo[1951:60b] <UILabel: 0x16d1aa60; frame = (15 70; 210 20); text = 'Choose a credit card'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x16d1c7f0>>


iOS 打印出视图中所有的子视图的名称

标签:http   io   os   使用   ar   for   2014   on   cti   

原文地址:http://blog.csdn.net/willyang519/article/details/39970695

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!