When is layoutSubviews called?

后端 未结 9 1663
忘掉有多难
忘掉有多难 2020-11-22 14:58

I have a custom view that\'s not getting layoutSubview messages during animation.

I have a view that fills the screen. It has a custom subview at the bo

9条回答
  •  逝去的感伤
    2020-11-22 15:26

    I had a similar question, but wasn't satisfied with the answer (or any I could find on the net), so I tried it in practice and here is what I got:

    • init does not cause layoutSubviews to be called (duh)
    • addSubview: causes layoutSubviews to be called on the view being added, the view it’s being added to (target view), and all the subviews of the target
    • view setFrame intelligently calls layoutSubviews on the view having its frame set only if the size parameter of the frame is different
    • scrolling a UIScrollView causes layoutSubviews to be called on the scrollView, and its superview
    • rotating a device only calls layoutSubview on the parent view (the responding viewControllers primary view)
    • Resizing a view will call layoutSubviews on its superview

    My results - http://blog.logichigh.com/2011/03/16/when-does-layoutsubviews-get-called/

提交回复
热议问题