UITableViewStyleGrouped 类型 tableView sectionHeader 高度问题

UITableViewStyleGrouped 类型的 tableView 在适配的时候出现很大的问题。记录一下spa

按照以前的方法,只须要执行如下的代码就可以很好的解决 section == 0 的时候,sectionHeader 的高度问题以及 section 间距的问题code

 
 
tableView.delegate = self;
tableView.dataSource = self;
tableView.sectionFooterHeight = 0.01f;
tableView.tableFooterView = [UIView new];

 

经过如下的方法可以良好的解决 sectionHeader 的高度问题,而且是兼容 iOS 10 以及其余版本的



- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 10.0f)]; return headerView; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ if (section == 0) { return 0.01; } return 10; } - (CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section { return 0.001; }
相关文章
相关标签/搜索