When is the layoutSubviews method called?

后端 未结 3 1777
粉色の甜心
粉色の甜心 2020-12-25 10:22

I am going through a tutorial that mentions the following method:

-(void)layoutSubviews

located in CustomerCell.m

When is this meth

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-25 11:07

    You will find your answer here

    EDIT: copied directly from the blog:

    • 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 it’s frame set only if the size parameter of the frame is different
    • scrolling a UIScrollView causes layoutSubviews to be called on the scrollView, and it’s superview
    • rotating a device only calls layoutSubview on the parent view (the responding viewControllers primary view)
    • removeFromSuperview – layoutSubviews is called on superview only

提交回复
热议问题