Skip to content

Commit 25fd228

Browse files
committed
fixed table headers and footer heights for iOS 11
1 parent 594cd5a commit 25fd228

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

Diff for: DataSource/DataSource+UITableViewDelegate.swift

+29-9
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ extension DataSource: UITableViewDelegate {
185185

186186
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
187187
let sectionDescriptor = self.sectionDescriptor(at: section)
188-
188+
189189
if let closure = sectionDescriptor?.headerHeightClosure ?? sectionHeaderHeight {
190190
return closure(visibleSection(at: section), section).floatValue(for: tableView.style)
191191
}
@@ -194,11 +194,21 @@ extension DataSource: UITableViewDelegate {
194194
return result
195195
}
196196

197-
if tableView.style == .plain {
198-
return tableView.sectionHeaderHeight
199-
} else {
200-
return UITableViewAutomaticDimension
197+
if let headerClosure = sectionDescriptor?.headerClosure ?? sectionHeader {
198+
let header = headerClosure(visibleSection(at: section), section)
199+
200+
switch header {
201+
case .title:
202+
return UITableViewAutomaticDimension
203+
case .view(let view):
204+
let height = view.bounds.height
205+
return height == 0 ? UITableViewAutomaticDimension : height
206+
default:
207+
return 0.0
208+
}
201209
}
210+
211+
return 0.0
202212
}
203213

204214
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
@@ -212,11 +222,21 @@ extension DataSource: UITableViewDelegate {
212222
return result
213223
}
214224

215-
if tableView.style == .plain {
216-
return tableView.sectionFooterHeight
217-
} else {
218-
return UITableViewAutomaticDimension
225+
if let footerClosure = sectionDescriptor?.footerClosure ?? sectionFooter {
226+
let footer = footerClosure(visibleSection(at: section), section)
227+
228+
switch footer {
229+
case .title:
230+
return UITableViewAutomaticDimension
231+
case .view(let view):
232+
let height = view.bounds.height
233+
return height == 0 ? UITableViewAutomaticDimension : height
234+
default:
235+
return 0.0
236+
}
219237
}
238+
239+
return 0.0
220240
}
221241

222242
// MARK: Display customization

0 commit comments

Comments
 (0)