tableView reloadData / reloadRowsAtIndexPaths导致滚动闪烁

时间:2015-11-26 08:00:06

标签: ios objective-c uitableview

我有一个带有50行自定义原型单元格的tableView。在Load more点击后,接下来应加载50条记录。

现在前50个记录顺利滚动,但在加载更多调用时,我在tableView上调用reloadData。现在tableView滚动不顺畅。我记录了索引,当我不断向上滚动时,我得到以下日志:

 index: 44
index: 43
index: 48
index: 49
index: 44
index: 43
index: 42
index: 47 // scrolls back causing flicker
index: 48 

我也试过reloadRowsAtIndexPaths,仍然是一样。

我该如何解决这个问题?我哪里出错了?我正在使用autolayout,是否会导致问题?

已修改的代码

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellProp" forIndexPath:indexPath];

//assign cell content

    return cell;
}

2 个答案:

答案 0 :(得分:0)

尝试使用

dequeueReusableCellWithIdentifier:forIndexPath:

答案 1 :(得分:0)

尝试:

let cell = tableView.dequeueReusableCellWithIdentifier("yourCellIdentifier", forIndexPath: indexPath)

当加载更多时,你不应该tableview.ReloadData()。使用:

tableView.insertRowsAtIndexPaths([indexpaths], withRowAnimation: UITableViewRowAnimation.Left)