向上滚动时,UITableView是跳跃/不稳定/不稳定

时间:2015-03-11 07:22:56

标签: ios uitableview

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

不仅对我自己的项目,我发现github(link)上的这个项目有同样的问题,所以你可以重现它。

1 个答案:

答案 0 :(得分:1)

你解决了这个问题吗?我终于解决了这个问题,关键是计算一个估计的高度。似乎你返回的估计越准确,跳跃/紊乱就越少。

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