美文网首页iOS开发及进阶之路
iOS 11 解决无法设置tableView的header和fo

iOS 11 解决无法设置tableView的header和fo

作者: 三创iOS和PHP开发 | 来源:发表于2018-01-25 15:09 被阅读223次

首先,需要将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和fo

    本文链接:https://www.haomeiwen.com/subject/mwcagxtx.html