Ich habe eine UITableView mit einer benutzerdefinierten Zelle, die ich füllen (mit Array-Infoservices) nach dem Parsen der XML-Daten.Verzögerung beim Aktualisieren von UITableView benutzerdefinierte Zelle
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
ApplicationCell *cell = (ApplicationCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[self.cellNib instantiateWithOwner:self options:nil];
cell = tmpCell;
self.tmpCell = nil;
}
infoService *e = [self.infoservices objectAtIndex:indexPath.row];
cell.name = [e infoName];
NSString *infodetails = [e infoDetails];
if (infodetails == nil) {
cell.details = @"Loading...";
[self startInfoDownload:e forIndexPath:indexPath];
NSLog(@"Loading...");
} else {
cell.details = infodetails;
NSLog(@"Show info detail: %@", infodetails);
}
return cell;
}
- (void)infoDidFinishLoading:(NSIndexPath *)indexPath
{
infoDownloader *infoserv = [imageDownloadsInProgress objectForKey:indexPath];
if (infoserv != nil)
{
[infoservices replaceObjectAtIndex:[indexPath row] withObject:infoserv.appRecord];
NSIndexPath *a = [NSIndexPath indexPathForRow:indexPath.row inSection:0]; // I wanted to update this cell specifically
ApplicationCell *cell = (ApplicationCell *)[self.tableView cellForRowAtIndexPath:a];
cell.details = [[infoservices objectAtIndex:[indexPath row]] infoDetails];
NSLog(@"Updating=%@", [[infoservices objectAtIndex:[indexPath row]] infoDetails]);
}
}
Für jede Zelle Ich verwende NSURLConnection sendAsynchronousRequest abrufen und XML-Daten aus Objekt infoDownloader mit
- (void)startDownload
für jede einzelne Zelle zu analysieren.
Nach Daten wurde erfolgreich analysiert Delegatmethode von infoDownloader
genannt wird- (void)infoDidFinishLoading:(NSIndexPath *)indexPath
Das Problem ist, dass, während die
- (void)infoDidFinishLoading:(NSIndexPath *)indexPath
nach dem Parsen jede Zelle aufgerufen wird und ich die
sehenNSLog(@"Updating=%@", [[infoservices objectAtIndex:[indexPath row]] infoDetails]);
im Debugger mit den richtigen Details, die Zelle d oes nicht sofort erfrischt aber nach 6 oder 7 Sekunden. Auch ist cellForRowAtIndexPath nicht von
- (void)infoDidFinishLoading:(NSIndexPath *)indexPath
aus irgendeinem Grunde aufgerufen, weil es nicht Debug-Ausgabe nach dem infoDidFinishLoading ist. Außerdem verstehe ich nicht, wie die cell.details tatsächlich aktualisiert wird, da cellForRowAtIndexPath nicht erneut aufgerufen wird.
Ich habe versucht, diese Funktion mit Apples LazyTableImages laden Beispiel, das ich erfolgreich verwendet habe, aber ich weiß nicht, was schief geht.