美文网首页
UITableViewAutomaticDimension适配

UITableViewAutomaticDimension适配

作者: 一誠 | 来源:发表于2019-06-10 20:45 被阅读0次

在iOS10.2上使用heightForHeaderInSection代理方法刷新头部,然而始终没有刷新,造成头部显示。网上查到这个问题是iOS11以下的问题,在iOS11以下系统使用UITableViewAutomaticDimension自动布局必须实现estimatedHeightForHeaderInSection这个方法或者设置estimatedSectionHeaderHeight属性。

tableView.estimatedSectionHeaderHeight = 100.0;
// 或者
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section {
 return 100.0;
}

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

相关文章

网友评论

      本文标题:UITableViewAutomaticDimension适配

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