码迷,mamicode.com
首页 > 其他好文 > 详细

viewDidLayoutSubviews 与 layoutSubviews 调用顺序

时间:2014-10-15 13:16:50      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:des   style   color   io   strong   sp   on   cti   ad   

了解演示demo的UI布局:

(lldb) po [[self view] recursiveDescription]

<UIView: 0x8d8f070; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x8d8f490>>

   | <ZQCustomView: 0x8c61130; frame = (0 0; 0 0); layer = <CALayer: 0x8c61220>>

   |    | <UIButton: 0x8f55530; frame = (100 100; 50 50); opaque = NO; layer = <CALayer: 0x8f59320>>

   |    |    | <UIButtonLabel: 0x8f594e0; frame = (9 16; 32 18); text = ‘ GO ‘; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x8f595d0>>


也即是:self.view 上添加个自定义的customView


打印调用的顺序:

TestFunctionCall[49445:60b] ---> -[ZQRootViewController viewDidLoad]

TestFunctionCall[49445:60b] ---> -[ZQCustomView initWithFrame:]

TestFunctionCall[49445:60b] ---> -[ZQRootViewController viewWillLayoutSubviews]

TestFunctionCall[49445:60b] ---> -[ZQRootViewController viewDidLayoutSubviews]

TestFunctionCall[49445:60b] ---> -[ZQCustomView layoutSubviews]

TestFunctionCall[49445:60b] ---> -[ZQCustomView layoutSubviews]

TestFunctionCall[49445:60b] ---> -[ZQCustomView drawRect:]


先调用试图控制器的viewWillLayoutSubviews 以及viewDidLayoutSubviews,然后调用view的layoutSubviews、layoutSubviews 。最后调用drawRect


viewDidLayoutSubviews 与 layoutSubviews 调用顺序

标签:des   style   color   io   strong   sp   on   cti   ad   

原文地址:http://blog.csdn.net/yadonghaoren/article/details/40108507

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