Update UIImageView in a UITableView cell with transparency
I have an imageview class that subclasses the UIImageView class, it is being displayed in an UITableView that dequeueReusableCellWithIdentifier.
@interface ImageView : UIImageView {
.
.
.
when it is time to update the image from one image to another, the update itself works
[self setImage:[UIImage imageWithContentsOfFile:[self resourcesDir:url]]];
but my images are transparent PNG (with the same dimensions) so part of the pervious image is visible under the updated one (since the cells themselves are reused)
I tried various ways to make the imageView clear itself first, but none work, this is what I tried:
self.image = nil;
[self setBackgroundColor:开发者_JS百科[UIColor clearColor]];
[self setNeedsDisplay];
[self performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO];
Any Idea ?
Be sure you are NOT using a new instance of the UIImageView. It must be the same instance for your code to work properly. You idea sounds like it should work properly.
精彩评论