為了設(shè)置高度為0,經(jīng)常在tableView:heightForHeaderInSection方法返回0或者負(fù)數(shù)都無效,無論怎么改tableView的sectionHeaderHeight和estimatedSectionHeaderHeight屬性也都無效。
有個(gè)辦法就是在heightForHeaderInSection返回CGFLOAT_MIN,如下代碼:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
// Removes extra padding in Grouped style
return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
// Removes extra padding in Grouped style
return CGFLOAT_MIN;
}
注意:
CGFLOAT_MIN在swift中的形式是CGFloat.min。設(shè)置tableView的
sectionHeaderHeight或estimatedSectionHeaderHeight為CGFLOAT_MIN都是無效的,最終還是要在tableView:heightForHeaderInSection方法返回CGFLOAT_MIN。