UIKitiOS开发常用知识点

UITableViewStyleGrouped模式下烦人的多余间

2016-12-21  本文已影响5646人  yanhooIT

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

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

每个section下边多余间距处理

// 隐藏UITableViewStyleGrouped下边多余的间隔
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return CGFLOAT_MIN;
}

补充:代码顺序的不同导致第一个section上边出现多余间距

tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
tableView.tableFooterView = [UIView new];
tableView.delegate = self;
tableView.dataSource = self;
tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
tableView.delegate = self;
tableView.dataSource = self;
tableView.tableFooterView = [UIView new];

参考文章

上一篇下一篇

猜你喜欢

热点阅读