I have a grouped UITableView where not all sections may be displayed at once, the table is driven by some data that not every record may have. My trouble is that the record
There is a convenient value for this case, called CGFloat.leastNonzeroMagnitude. Use it as follows:
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return .leastNonzeroMagnitude
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return .leastNonzeroMagnitude
}
You can also use tableView.sectionHeaderHeight = 0 and tableView.sectionFooterHeight = 0, but this will be applied for all headers and footers. With the delegate solution you're still able to manipulate different headers' and footers' height, but use .leastNonzeroMagnitude as a default