美文网首页iOS技术
解决TableView Group 顶部空白

解决TableView Group 顶部空白

作者: 魔芋Brace | 来源:发表于2017-05-04 16:41 被阅读99次

通常设置UITableView style 为Group时,顶部会出现大概50像素的空白,

实际是默认的tableHeaderView 的位置;

解决方案为:

CGRect frame = CGRectMake(0, 0, 0, 0.1);//关键设置view的高度
self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:frame];

给tableHeaderView一个很小的高度即可;

若设置tableHeaderView = nil;他会使用默认填充空白。

若遇到seciton header 或 footer 有10像素间距时,也需要设置去高度为 0.1则可解决。

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.1f;
}

相关文章

网友评论

    本文标题:解决TableView Group 顶部空白

    本文链接:https://www.haomeiwen.com/subject/ytoexttx.html