tableView group样式 第一个 cell 从y 35开始

group样式的 tableview, 默认第一个cell 是从35开始的,需要

添加如下代码,使之从零开始

        _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, mScreenWidth, 0.001)];

如图所示,当设置过tableHeaderView之后,如果不设置,estimatedSectionHeaderHeight ,只在代理方法

中配置高度

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01;
}

发现,代理方法中的高度只在第一个分区起作用了

如果我们需要展示正常,则需要添加如下代码

        _tableView.estimatedSectionHeaderHeight = 0.01;

这时候就展示正常了

由此可知,我们如果需要正常展示grouped 风格tableview的区头,

则需要三步

1         _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, mScreenWidth, 0.001)];

2    _tableView.estimatedSectionHeaderHeight = 0.01

3  代理方法中配置高度

猜你喜欢

转载自blog.csdn.net/LIUXIAOXIAOBO/article/details/113979864