iOS11下段头和段尾高度计算不正确的原因

iOS11中如果不实现tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? 和 tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? 这两个方法,那么tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat 和 tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat 这两个方法不会被调用

这是因为tableView.estimatedRowHeight、tableView.estimatedSectionHeaderHeight、tableView.estimatedSectionFooterHeight 三个高度的估算属性由默认的0变成了UITableViewAutomaticDimension,导致高度计算不对

解决方法是实现对应的方法 或者 把这三个属性设置为0

案例:


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

推荐阅读更多精彩内容