@@ -185,7 +185,7 @@ extension DataSource: UITableViewDelegate {
185
185
186
186
public func tableView( _ tableView: UITableView , heightForHeaderInSection section: Int ) -> CGFloat {
187
187
let sectionDescriptor = self . sectionDescriptor ( at: section)
188
-
188
+
189
189
if let closure = sectionDescriptor? . headerHeightClosure ?? sectionHeaderHeight {
190
190
return closure ( visibleSection ( at: section) , section) . floatValue ( for: tableView. style)
191
191
}
@@ -194,11 +194,21 @@ extension DataSource: UITableViewDelegate {
194
194
return result
195
195
}
196
196
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
+ }
201
209
}
210
+
211
+ return 0.0
202
212
}
203
213
204
214
public func tableView( _ tableView: UITableView , heightForFooterInSection section: Int ) -> CGFloat {
@@ -212,11 +222,21 @@ extension DataSource: UITableViewDelegate {
212
222
return result
213
223
}
214
224
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
+ }
219
237
}
238
+
239
+ return 0.0
220
240
}
221
241
222
242
// MARK: Display customization
0 commit comments