I have a UITableView
, which I fill this way:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyData *myData = [arrayData objectAtIndex:indexPath.row];
MyTableViewCell *cell = [[MyTableViewCell alloc] init:myData.title
:myData.url];
return cell;
}
There is an UIImageView
in MyTableViewCell
, I load it like this:
- (id) init : (NSString *) parTitle : (NSString *) parUrl {
// ...
[self load:parUrl];
// ...
}
- (void) load : (NSString *) url {
NSURL *myURL = [NSURL URLWithString:url];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 18, 70, 65)];
NSData *imageData = [NSData dataWithContentsOfURL:myURL];
dispatch_async(dispatch_get_main_queue(), ^{
// Update the UI
[image setImage:[UIImage imageWithData:imageData]];
image.contentMode = UIViewContentModeScaleAspectFit;
[self.contentView addSubview:image];
[self reloadInputViews];
});
});
}
The problem is that every time a cell disappears from the screen, it reloads its content when I scroll back, but I don't want it. What to do? Thanks for your help.