I know this probably has been asked before but I am having issues with the dequeue. Basically, i am using an async image loading in the cells in some sort of grid.
So essentially, I add left , middle and right image for a 3 column table which is fairly simple. I set the number of rows to 15(about 45 cells in all) and set the image url for each of them from an array.
For some reason the first 16 cells get repeated at the bottom and when the async image loading kicks in they get replaced by the right images. If I replace remove the dequeue stuff, it all loads fine and it doesn't repeat the first 16 block around 3 times.
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];
cell.contentView.autoresizesSubviews = YES;
cell.contentView.clipsToBounds = YES;
cell.backgroundColor = [UIColor clearColor];
Asynimage *leftImage;
leftImage = [[Asynimage alloc] initWithFrame:CGRectMake(0,0,IMG_SIZE,IMG_SIZE)];
leftImage.tag = 10;
[cell.contentView addSubview:leftImage];
Asynimage *middleImage;
middleImage = [[Asynimage alloc] initWithFrame:CGRectMake(IMG_SIZE,0,IMG_SIZE,IMG_SIZE)];
middleImage.tag = 20;
[cell.contentView addSubview:middleImage];
Asynimage *rightImage;
rightImage = [[Asynimage alloc] initWithFrame:CGRectMake(IMG_SIZE*2,0,IMG_SIZE,IMG_SIZE)];
rightImage.tag = 30;
[cell.contentView addSubview:rightImage];
}
Asynimage *leftImage=(Asynimage*)[cell.contentView viewWithTag:10];
Asynimage *middleImage=(Asynimage*)[cell.contentView viewWithTag:20];
Asynimage *rightImage=(Asynimage*)[cell.contentView viewWithTag:30];
/*Set the urls on those 3 then do the loadimagefrom url*/
The deque does not duplicate the rows, but it triggers the reuse of cells, which were instantiated before for rows not visible anymore, to optimize memory usage. The effect is exactly what you describe as duplication. Populate reused cells with subviews, after they get dequed. Store the async images in an array and use the row index to put them on the right cell.