コードと重複している可能性があるものを確認するには、次の UIVIew カテゴリを追加します。
@interface UIView (Dumper_Private)
+ (void)appendView:(UIView *)v toStr:(NSMutableString *)str;
@end
@implementation UIView (Dumper_Private)
+ (void)appendView:(UIView *)a toStr:(NSMutableString *)str
{
[str appendFormat:@" %@: frame=%@ bounds=%@ layerFrame=%@ tag=%d userInteraction=%d alpha=%f hidden=%d\n",
NSStringFromClass([a class]),
NSStringFromCGRect(a.frame),
NSStringFromCGRect(a.bounds),
NSStringFromCGRect(a.layer.frame),
a.tag,
a.userInteractionEnabled,
a.alpha,
a.isHidden
];
}
@end
@implementation UIView (Dumper)
+ (void)dumpSuperviews:(UIView *)v msg:(NSString *)msg
{
NSMutableString *str = [NSMutableString stringWithCapacity:256];
while(v) {
[self appendView:v toStr:str];
v = v.superview;
}
[str appendString:@"\n"];
NSLog(@"%@:\n%@", msg, str);
}
+ (void)dumpSubviews:(UIView *)v msg:(NSString *)msg
{
NSMutableString *str = [NSMutableString stringWithCapacity:256];
if(v) [self appendView:v toStr:str];
for(UIView *a in v.subviews) {
[self appendView:a toStr:str];
}
[str appendString:@"\n"];
NSLog(@"%@:\n%@", msg, str);
}
@end
そして電話する[UIView dumpSuperviews:theSegmentedControl];