XZ_iOS reloadData 刷新页面导致页面上移的问题解决

仅仅是使用 tableView.reloadData() 这句代码,导致了下图:

在不上滑tableView的情况下,点击全选,没有任何的问题,当滑动tableView的底部时,点击全选,tabelView发生了上移。

最初的解决是想着刷新的时候不要动画,直接刷新,还是有问题:

不过可以确定的是,确实是动画的原因导致的,最终解决:

let reloadSet = IndexSet(integer: 0)
UIView.performWithoutAnimation {
  tableView.reloadSections(reloadSet, with: .none)
}

或者是以下的解决方式:

tableView.estimatedRowHeight = 0
tableView.estimatedSectionHeaderHeight = 0
tableView.estimatedSectionFooterHeight = 0
发布了208 篇原创文章 · 获赞 52 · 访问量 14万+

猜你喜欢

转载自blog.csdn.net/understand_XZ/article/details/91414700