向上滚动时,UITableView跳动/不连贯/生涩 [英] UITableView is jumpy/choppy/jerky when scrolling up

查看:50
本文介绍了向上滚动时,UITableView跳动/不连贯/生涩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用UITableView时遇到了此问题,tableView的单元格具有不同的高度,并且自动布局约束已正确设置.当您向下滚动到tableView的底部并加载更多数据(无论使用reloadData或insertRowsAtIndexPaths),然后向上滚动时,tableView会在某个时候开始跳动,然后一直跳动,直到滚动到最顶端.

I encountered this problem when using UITableView, the tableView's cells have different heights, and the auto layout constraints are set properly. When you scroll down to the bottom of tableView and load more data (no matter by using reloadData or insertRowsAtIndexPaths), and then scroll up, the tableView will start to be jumpy at some point, and then be jumpy all the time until you scroll to the very top.

不仅对于我自己的项目,我还在github上找到了这个项目(链接)有相同的问题,以便您可以重现.

Not only for my own project, I find this project on github (link) have the same problem so that you can reproduce it.

推荐答案

您解决了这个问题吗?我终于解决了这个问题,关键是要计算一个估计的高度.似乎您返回的估算值越准确,跳动/波动性就越小.

Did you solve the problem? I finally solved this issue, the key is to calculate an estimated height. Seems like the more accurate estimate you return, the less jumpiness/choppiness.

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
 switch (yourTypeOfCell) {
     case something:
        return estimatedHeight;
        break;
     case default:
        return defaultValue;
        break;
 }
}

这篇关于向上滚动时,UITableView跳动/不连贯/生涩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆