Hi there,
I use the following code to trigger image downloads in visible cells/paths:
- (void)loadImagesForOnScreenrows {
NSArray *visiblePaths = [tableView indexPathsForVisibleRows];
for (NSIndexPath *indexPath in visiblePaths) {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if([cell viewWithTag:kTagImageView] != nil) {
(ImageViewCached *)[[cell viewWithTag:kTagImageView] triggerDownload];
}
}
}
// Load images for all onscreen rows when scrolling is finished
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
if (!decelerate)
{
[self loadImagesForOnscreenRows];
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
[self loadImagesForOnscreenRows];
}
However, apparently the indexPaths returned do not reflect the actual onscreen rows.
Especially if I scroll fast, the rows returned will be ones that are already off screen.
Can anyone think of a good (probably obvious) reason why that would be the case?