From 319a8b86eeaf2b870a1a308e3996012abda6cfec Mon Sep 17 00:00:00 2001 From: Robert Tolar Haining Date: Mon, 28 Aug 2017 15:28:24 -0400 Subject: [PATCH] fixes footer and header heights on ios 11 to be automatic dimension if the view returns as 0 (#109) --- Static/DataSource.swift | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Static/DataSource.swift b/Static/DataSource.swift index fbb4c96..4cfce67 100644 --- a/Static/DataSource.swift +++ b/Static/DataSource.swift @@ -204,7 +204,13 @@ extension DataSource: UITableViewDataSource { } public func tableView(_ tableView: UITableView, heightForHeaderInSection sectionIndex: Int) -> CGFloat { - return section(at: sectionIndex)?.header?.viewHeight ?? 0 + guard let headerView = section(at: sectionIndex)?.header else { return 0 } + + var headerHeight = headerView.viewHeight + if headerHeight == 0 { + headerHeight = UITableViewAutomaticDimension + } + return headerHeight } public func tableView(_ tableView: UITableView, titleForFooterInSection sectionIndex: Int) -> String? { @@ -216,7 +222,13 @@ extension DataSource: UITableViewDataSource { } public func tableView(_ tableView: UITableView, heightForFooterInSection sectionIndex: Int) -> CGFloat { - return section(at: sectionIndex)?.footer?.viewHeight ?? 0 + guard let footerView = section(at: sectionIndex)?.footer else { return 0 } + + var footerHeight = footerView.viewHeight + if footerHeight == 0 { + footerHeight = UITableViewAutomaticDimension + } + return footerHeight } public func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {