1

I'm trying to implement an infinite UITableView. I load some information from the server in chunks and I want to dynamically add this information to the tableview when user scrolls the table.

The problem I'm facing : I have an initial tableview with 40 elements and then in scrollViewDidScroll I check if last visible row's indexPath == [myData count] - 20 (so when user has already scrolled half of the list I load next content) I load next 40 elements of content from the server and only when last visible row's indexPath == [myData count] -1 I actually reload the tableview. So as you see i make some eager caching in order to make tableview reloading faster.Everything work perfectly but when I begin to scroll my table really fast data stopped loading. It seems that this check: last visible row's indexPath == [myData count] - 20 has actually no chance to implement because of fast scrolling.I can't see any other obvious reasons for this. So has someone some answer for this weird problem?

P.S. Or may be I should try reloadRowsAtIndexPaths instead of reloading the whole table?

4

1 回答 1

1

也许有了这个代表,你就有机会提前做点什么。也可以只重新加载可见行,这比重新加载数据要好。

-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
    NSArray *paths = [self.tableView indexPathsForVisibleRows];
    int tmprow = [[paths objectAtIndex:0] row];
}
于 2013-09-12T18:20:19.917 回答