Self-sizing Table View Cells | raywenderlich.com

In this tutorial, you’ll learn how to enable self-sizing table view cells, as well as how to make them resize on-demand and support Dynamic Type.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/8549-self-sizing-table-view-cells

if I include stackview works the same?

@kevcol Can you please help with this when you get a chance? Thank you - much appreciated! :]

Even not writing the tableView.rowHeight = UITableView.automaticDimension and the tableView.estimatedRowHeight = 600 statements in the viewDidLoad(), the self-sizing table view cells still can work correctly. I am not sure the two statements are mandatory requirement?

@kevcol Can you please help with this when you get a chance? Thank you - much appreciated! :]

The default value for both rowHeight and estimatedRowHeight is automaticDimension, so in this case you don’t have to set them.

Setting rowHeight in code will make sure it is set right, even if the storyboard somehow got another value set.

The estimated height is just about improving scroll response by telling it what to expect, but it will still work even if the estimate is not very good.

Thanks a lot for your detailed explanation.

@kevcol, when you say every subview needs to have a top, bottom, left, and right constraint, does that mean even subviews that are in a stack view in the cell or do I just need to be sure the stack view has top, bottom, left, and right constraints?

@kevcol Can you please help with this when you get a chance? Thank you - much appreciated! :]

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!