Return CGFLOAT_MIN
instead of 0 for your desired section height.
Returning 0 causes UITableView to use a default value. This is
undocumented behavior. If you return a very small number, you
effectively get a zero-height header.
Swift 3:
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 0 {
return CGFloat.leastNormalMagnitude
}
return tableView.sectionHeaderHeight
}
Swift:
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 0 {
return CGFloat.min
}
return tableView.sectionHeaderHeight
}
Obj-C:
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0)
return CGFLOAT_MIN;
return tableView.sectionHeaderHeight;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…