您好,欢迎来到伴沃教育。
搜索
您的当前位置:首页iOS11下段头和段尾高度计算不正确的原因

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

案例:

Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务