设置UITableView的section header或foo

2016-09-08  本文已影响0人  jezong

为了设置高度为0,经常在tableView:heightForHeaderInSection方法返回0或者负数都无效,无论怎么改tableView的sectionHeaderHeightestimatedSectionHeaderHeight属性也都无效。

有个办法就是在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;

}

注意:

  1. CGFLOAT_MIN在swift中的形式是CGFloat.min

  2. 设置tableView的sectionHeaderHeightestimatedSectionHeaderHeightCGFLOAT_MIN都是无效的,最终还是要在tableView:heightForHeaderInSection方法返回CGFLOAT_MIN

上一篇下一篇

猜你喜欢

热点阅读