Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is the layoutSubviews method called?

Tags:

ios

iphone

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

-(void)layoutSubviews

located in CustomerCell.m

When is this method called during the app execution? Is it automatically invoked? I dont see any callback.

like image 612
tranvutuan Avatar asked Apr 02 '12 20:04

tranvutuan


1 Answers

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
like image 115
skytz Avatar answered Sep 30 '22 17:09

skytz