I have a simple UITableView (sample project here) but the section headers do not respect the height I'm setting in the heightForHeaderInSection
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 40;
}
The table view looks like this. The 1 section header has a correct height but not the other ones.
When I inspect the view with the Reveal app, it seems that there is a kind of footer after the last cell in the section.
What am I doing wrong?
What seems to work is this
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.0001f; // 0.0f does not work
}
or even better, in loadView
self.tableView.sectionFooterHeight = 0.0f;
Swift:
Swift version of approved answer:
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return CGFloat.leastNonzeroMagnitude
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With