Ich versuche, meine Tabellenansicht mit Zellen zu laden, die Bilder enthalten, die aus dem Internet heruntergeladen wurden. Ich möchte den Download-Vorgang nur für derzeit sichtbare Zellen durchführen, anstatt jedes Bild herunterzuladen, wenn der Benutzer schnell nach unten scrollt.Bild nur für sichtbare Zeile in der Tabellenansicht konfigurieren
Ich fand diese beim Surfen, aber es viel Stackoverflow nicht hilft:
- (void)configureVisibleCellsForTableView:(UITableView *)tableView animated:(BOOL)animated {
[self tableView:tableView configureRowsAtIndexPaths:tableView.indexPathsForVisibleRows animated:animated];
}
- (void)tableView:(UITableView *)tableView configureRowsAtIndexPaths:(NSArray *)indexPaths animated:(BOOL)animated {
for (NSIndexPath *indexPath in indexPaths) {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell) {
[self tableView:tableView configureCell:cell forRowAtIndexPath:indexPath animated:animated];
}
}
}
- (void)tableView:(UITableView *)tableView configureCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated {
// Cell configuration
}
was ist der beste Weg, dies
Haben Sie genommen einen Blick auf Tableview (_ refrenced Download abzubrechen: willDisplayCell: forRowAtIndexPath :? - dies vor einem cel genannt wird l wird gezeichnet, wie in der Dokumentation beschrieben - https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewDelegate_Protocol/#//apple_ref/occ/intfm/UITableViewDelegate/tableView:willDisplayCell:forRowAtIndexPath: – Daven