Row Heights
Self-sizing rows that adapt to your content automatically.
Automatic Heights
Enable self-sizing rows with a single line:
var config = DataTableConfiguration()
config.rowHeightMode = .automatic(estimated: 60)The estimated parameter provides an initial height before measurement. Pick something close to your typical row height for smooth scrolling.
How It Works
- Initial layout - Rows use the estimated height
- Lazy measurement - As rows scroll into view, they're measured via Auto Layout
- Height caching - Measured heights are cached for reuse
- Scroll anchoring - Scroll position is preserved when heights change
With Text Wrapping
var config = DataTableConfiguration()
config.textLayout = .wrap
config.rowHeightMode = .automatic(estimated: 60)
config.maxColumnWidth = 250 // Force wrapping by capping widthFixed Height
For uniform rows where all content fits in the same height:
config.rowHeightMode = .fixed(44)Fixed heights are fastest - use them when all rows have single-line text and uniform content.
Live Height Updates
When cell content changes during editing, update the height without reloading:
func textViewDidChange(_ textView: UITextView) {
// Update your model
notes[rowIndex].content = textView.text
// Remeasure the row - keyboard stays up, no cell reload
dataTable.remeasureRow(rowIndex)
}Large Datasets (100k+ rows)
config.rowHeightMode = .automatic(estimated: 44, prefetchWindow: 10)The prefetch window measures rows ahead of the visible area for smoother scrolling.