Hello!
I have a table with custom tableviewcells, this cells have an imageview who retrieves his image from an url (all images are diferent).
The problem is that the table appear when all pictures are downloaded, and have a delay when the user scrolls, for the same reason.
Is posible to download the pictures asynchronously, and when each one is downloaded put it in the table cell? and how??
This is my code, thank you:
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"OfertasCellIdentifier";
OfertasCell *cell = (OfertasCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"OfertasCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
NSString *urlImg = [[ofertas objectAtIndex:indexPath.row] objectForKey:@"imagen"];
img = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString:urlImg]]];
[cell.imagen setImage:img];
// Set up the cell...
return cell;
}