UITableViewAutomaticDimension适配

2019-06-10  本文已影响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;
}
上一篇 下一篇

猜你喜欢

热点阅读