iOS 解决tableview contensize 预估值不准

iOS 解决tableview contensize 预估值不准

开发中,遇到一个问题,要在tableview列表上加水印。所以我就使用了tableview.contentsize.height作为水印的高度,结果滑动时发现了水印的高度渲染的不对,接下来就打印了tableview.contentsize.height的值,原来是预估的,随着滑动会发生变化。关闭预估值,只需设置:
tableView.estimatedRowHeight = 0;
tableView.estimatedSectionHeaderHeight = 0;
tableView.estimatedSectionFooterHeight = 0;


In iOS 11, table views use estimated heights by default. This means that the contentSize is just as estimated value initially. If you need to use the contentSize, you’ll want to disable estimated heights by setting the 3 estimated height properties to zero:

tableView.estimatedRowHeight = 0;

tableView.estimatedSectionHeaderHeight = 0;

tableView.estimatedSectionFooterHeight = 0;

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容