IOS开发札记

//遍历所有的子控件,并打印其Frame
+(NSString *)searchAllSubviews:(UIView *)superview
{
NSMutableString *xml = [NSMutableString];
NSString *class = NSStringFromClass( superview.class );
class = [class stringByReplacingOccurrencesOfString: @"_" withString: @""];
[xml appendFormat:@"<%@ frame = "%@">\n" , class, NSStringFromCGRect( superview.frame)];
for (UIView *child in super.subviews){
NSString *subViewXml = [self searchAllSubviews : childView];
[xml appendString : subviewXml];
}
[xml appendFormat 😡"<%@>\n",class];
return xml;
}

block外的变量不能在block中修改
若想改变则应在变量前加上__block

posted @ 2015-08-20 23:22  WillkYang  阅读(152)  评论(0编辑  收藏  举报