レイアウトの階層を表示
Android だとレイアウトの階層構造が見れる hierarchy view perspective があるんですが、
Xcode だとそういうのがパッと見みつからなかったのでどうやってレイアウトの状態を把握するのだろうと思っていたところ、教えてもらったのでメモ。
UIView に対して recursiveDescription を呼び出す
通常のメソッド呼び出しでは呼べないので performSelector する。
UIViewController の view の階層を見るときは以下の様な感じ。
NSLog(@"%@", [self.view performSelector:@selector(recursiveDescription)]);
出力は以下の様な感じ。
2013-08-17 21:04:53.358 UIViewControllerTest[60940:11303] <UIView: 0x76935f0; frame = (0 20; 320 460); autoresize = W+H; layer = <CALayer: 0x7693650>> | <UIRoundedRectButton: 0x7692130; frame = (25 397; 63 44); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x7691940>> | | <UIGroupTableViewCellBackground: 0x7692200; frame = (0 0; 63 44); userInteractionEnabled = NO; layer = <CALayer: 0x7691970>> | | <UIImageView: 0x76929d0; frame = (1 1; 61 43); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x7692380>> - (null) | | <UIButtonLabel: 0x7692480; frame = (12 12; 39 19); text = 'show'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x7692520>> | <UIView: 0x76932f0; frame = (0 0; 320 224); clipsToBounds = YES; autoresize = LM+RM; layer = <CALayer: 0x7693290>> | <UIRoundedRectButton: 0x768df00; frame = (232 412; 55 44); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x768e020>> | | <UIGroupTableViewCellBackground: 0x768e800; frame = (0 0; 55 44); userInteractionEnabled = NO; layer = <CALayer: 0x768e8d0>> | | <UIImageView: 0x768f940; frame = (1 1; 53 43); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x7690050>> - (null) | | <UIButtonLabel: 0x768f520; frame = (12 12; 31 19); text = 'hide'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x768f610>> | <UIRoundedRectButton: 0x7692710; frame = (229 361; 71 44); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x76927e0>> | | <UIGroupTableViewCellBackground: 0x7692810; frame = (0 0; 71 44); userInteractionEnabled = NO; layer = <CALayer: 0x7692890>> | | <UIImageView: 0x7693770; frame = (1 1; 69 43); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x7693e90>> - (null) | | <UIButtonLabel: 0x7693fa0; frame = (12 12; 47 19); text = 'switch'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x7694040>> | <UIRoundedRectButton: 0x7691190; frame = (96 412; 129 44); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x7691260>> | | <UIGroupTableViewCellBackground: 0x7691290; frame = (0 0; 129 44); userInteractionEnabled = NO; layer = <CALayer: 0x7691310>> | | <UIImageView: 0x7691380; frame = (1 1; 127 43); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x76913e0>> - (null) | | <UIButtonLabel: 0x7691540; frame = (12 12; 104 19); text = 'view hierarchy'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x7691630>>
ログ出力なのであまり見やすくはないけど、何もないよりはマシですね。