I'm having some problems updating UITableViewCells after asynchronously loading a cell image. I use custom UITableViewCells like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"productCell";
MainTableViewCell *cell = (MainTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[MainCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"productCell"] autorelease];
}
}
I have a class that is a UITableViewCell, and then a class that executes the entire drawing. This is an example of Apple code called "AdvancedTableViewCells", and I'm doing the composition.
I have images in my cells that I upload asynchronously using an example Apple code called "LazyTableImages". Here is the delegate that should update the cell:
- (void)coverImageDidLoad:(NSIndexPath *)indexPath {
CoverImageAsyncLoader *coverImageAsyncLoader = [imageDownloadsInProgress objectForKey:indexPath];
if (coverImageAsyncLoader != nil) {
MainTableViewCell *cell = (MainTableViewCell *)[self.tableView cellForRowAtIndexPath:coverImageAsyncLoader.indexPathInTableView];
if (coverImageAsyncLoader.products.coverImage != nil) {
cell.productCover = coverImageAsyncLoader.products.coverImage;
} else {
cell.productCover = blankCoverImage;
}
}
}
. , , , , . :
[cell setNeedsDisplay]
[cell.contentView setNeedsDisplay]
:
cell = [[[MainCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"productCell"] autorelease];
.
:( , .