iOS UITableView heightForHeaderInSection不调用

UITableView设置为Group样式。

不走heightForHeaderInSection/heightForFooterInSection方法。

对于没隐藏苹果原生的navigationBar的。

解决办法:

主题 : iOS11 heightForHeaderInSection设置高度无效

总结:

iOS11默认开启Self-Sizing,关闭Self-Sizing即可。

self.tableView.estimatedRowHeight = 0; 

self.tableView.estimatedSectionHeaderHeight = 0;

self.tableView.estimatedSectionFooterHeight = 0;


对于隐藏了苹果原生navigationBar,用UIView自己写navigationBar的。

可能是没有实现tableView: viewForHeaderInSection:/tableView: viewForFooterInSection:造成的。

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

        return 10;

}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

        return [[UIView alloc] init];

} //viewForFooterInSection同理

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。