开发者

removeFromSuperView is not working?

开发者 https://www.devze.com 2023-01-11 20:32 出处:网络
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,

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消