I have a UITableView where in some instances, certain sections have zero rows. My goal is that when this is true, I don\'t want any wasted space in the table view, it should
I use the following solution:
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return section == 0 ? CGFloat.leastNormalMagnitude : 8 } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return 0 }
Result: