UITableview调用reload方法时抖动问题
由于UITableview在iOS11的时候加入了Self-Sizing新特性,而且cell、header、footer是默认开启的,导致estimated的高度值变成了UITableViewAutomaticDimension(之前是0)。
如果不曾设置过estimateRowHeight属性的话,reload的时候可能会有一些奇怪的上下抖动,UITableview的位置也有可能不再停留在原来的位置。
解决方案就是给这些预估值赋值为0来禁用:
if (@available(iOS 11.0, *)) {
UITableView.appearance.estimatedRowHeight = 0;
UITableView.appearance.estimatedSectionFooterHeight = 0;
UITableView.appearance.estimatedSectionHeaderHeight = 0;
}
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 风屋
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果