UITableView visibleCells (in section?)

I have X partitions. I want to be lazy to upload images to different user cells for each partition. Is there a better way to do this than to check every time if cellArray.object (visibleCells) is equal to Ccell in which I want to load these images?

UPDATE: Here is the working code (for now ...). My code is based on the example of Adrian Kosmachevsky here .

- (void)loadContentForVisibleCellsInSection{

    NSArray *visiblePaths = [self.tableView indexPathsForVisibleRows];
    for (NSIndexPath *indexPath in visiblePaths)
    {
        switch (indexPath.section) {
            case 0:{    
                CustomCell *cell = (CustomCell *)[self.tableView cellForRowAtIndexPath:indexPath];
                [cell loadImage];
            }               
                break;
            default:
                break;
        }

    }

}
+3
source share
1 answer

Instead of listing all your cells for visibility check, use

[tableView indexPathsForVisibleRows]

. Apple: LazyTableImages

+4

Source: https://habr.com/ru/post/1735767/


All Articles