From 7132a0a548e0c91cbc595e486a3c7029f63c683f Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Mon, 24 Oct 2016 16:14:47 +0300 Subject: [PATCH] automatic cell registration improvement --- Sources/TableDirector.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index 24dfeb5..5592a1e 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -101,6 +101,11 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { open func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { let row = sections[indexPath.section].rows[indexPath.row] + + if rowHeightCalculator != nil { + cellRegisterer?.register(cellType: row.cellType, forCellReuseIdentifier: row.reuseIdentifier) + } + return row.estimatedHeight ?? rowHeightCalculator?.estimatedHeight(forRow: row, at: indexPath) ?? UITableViewAutomaticDimension } @@ -108,7 +113,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { let row = sections[indexPath.section].rows[indexPath.row] - if shouldUsePrototypeCellHeightCalculation { + if rowHeightCalculator != nil { cellRegisterer?.register(cellType: row.cellType, forCellReuseIdentifier: row.reuseIdentifier) }