iOS 11 解决无法设置tableView的header和footer的高度问题

首先,需要将tableview的style设置为UITableViewStyleGrouped。然后,加入如下代码即可解决iOS 11中无法设置tableView的header和footer的高度问题:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    
    return [[UIView alloc] init];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {

    return 0.0f;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    return [[UIView alloc] init];
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {

    
    return 20.0f;
    
}

你可能感兴趣的:(iOS 11 解决无法设置tableView的header和footer的高度问题)