removeFromSuperView is not working?
I am trying to use MikeJ's technique for loading images into a TableViewCell asynchronously. However, I am running into one issue. The images are loading okay for me, but when I scroll down the list, the cells that don't have the ima开发者_运维百科ge loaded yet would have an erroneous image showing until the correct image is fetched. I have drilled down the problem to the part where I am removing the old image view from the cell ( this is inside of the tableView:cellForRowAtIndexPath: method ) :
image = (AsyncImageView *)[cell viewWithTag:0];
...
NSLog(@"\tremoving from superview: %@", image);
[image removeFromSuperview];
NSLog(@"\tviewWithTag: 0 %@", [cell viewWithTag:0]);
My logging showed that removeFromSuperview was not working: it was still part of the cell after the call to removeFromSuperview. This is causing the erroneous image to should up in the other list items.
So, I guess the question is, how do I remove it from the cell?
0 is the default tag. I suspect [cell viewWithTag:0] returns cell:
The view in the receiver’s hierarchy that matches tag. The receiver is included in the search.
精彩评论