1

I am just thinking what is the advantage to set up frames, coordinates / sizes in layoutSubviews in case UITableViewCell is subclassed vs directly when cell is created in cellForRowAtIndexPath?

As I see if autoresizingmask properly do his job to set views frame size meanwhile rotation, then cellForRowAtIndexPath should be enough to use?!

Scott Berrevoets
  • 16,921
  • 6
  • 59
  • 80
János
  • 32,867
  • 38
  • 193
  • 353

1 Answers1

3

Separation of concerns and Single responsibility principle.

It's the cell's job to determine how to lay out its subviews (hence the method layoutSubviews), not the tableView's data source. If the cell needs information, it's the data source's responsibility to give the cell that information, but after that the cell should be laying itself out.

Scott Berrevoets
  • 16,921
  • 6
  • 59
  • 80
  • I prefer this: *use `layoutSubviews` to perform additional manual changes above and beyond any autoresizing behaviours* – János Sep 02 '14 at 07:29