0
votes

Assume I want a table with 3 rows. Each row is a different height. I'm not using any layout constraints and all coding is done in Swift (no xib, visual layout, property sheets). I'm subclassing UITableViewCell and using layoutSubviews to assign views to x,y coordinates.

All is well except for determining row height. I'm really at a loss as to proper way to proceed.

In heightForRowAt, I need contentView width to calc height. I don't know how to get contentView width. For example, after rotating device, heightForRowAt is called before layoutSubviews, so I don't know content width of cell. Content width might be smaller than tableView due to safe areas (landscape), edit mode items (red circle), etc.

Any suggestions would be appreciated.