UITableViewStyleGrouped留白问题

[[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped]

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

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

顺序颠倒会导致UITableViewStyleGrouped类型UITableView的效果造成不一样的影响
1.在设置代理后设置tableFooterView,上边不会出现多余间距
tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
tableView.delegate = self;
tableView.dataSource = self;
tableView.tableFooterView = [UIView new];

2.在设置代理前设置tableFooterView,上边会出现多余间距
tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
tableView.tableFooterView = [UIView new];
tableView.delegate = self;
tableView.dataSource = self;

第一个section上边多余间距处理

// 隐藏UITableViewStyleGrouped上边多余的间隔
_tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {

    return nil

}

posted @ 2017-10-25 11:31  JustToGo  阅读(852)  评论(0编辑  收藏  举报