我采用的是将tableView设置为UITableViewStyleGrouped,但是设置之后需要对界面进行一系列的调整
如何去除tableView的顶部留白?
分组类型的tableView存在默认数值的header与footer,以下为处理方式:
方法一:
(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 0.1;//return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.1;//return CGFLOAT_MIN;
}
若返回值为0,系统会认为是默认数值而返回默认高度,另外0.1与 CGFLOAT_MIN 等效.
方法二:
tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, CGFLOAT_MIN)];
tableView.tableFooterHeight = 0;
PS:若你需要设置SectionHeader的title,可以将tableHeaderHeight设置为30
参考链接:http://blog.youkuaiyun.com/fantasy_jun/article/details/69787408
参考链接:http://blog.sina.com.cn/s/blog_133384b110102wk8b.html