无法从ImageVIew中清除TableView中重用单元格中的图像 [英] Image in reused cell in a TableView not being cleared from ImageVIew

查看:42
本文介绍了无法从ImageVIew中清除TableView中重用单元格中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Tableview,其中包含带有图像的单元格,但是被重用的单元格仍包含来自先前被重用的单元格中的图像,直到下载并设置新图像为止.

I have a Tableview containing cells with images, however the cells that are reused still contain the image from the previous cell that is being reused until the new image is downloaded and set.

我尝试将图像设置为nil.(imageV是HJManagedImageV的子类,可在以下位置找到源: HJManagedImageV

I have tried setting the image to nil. (imageV is a subclass of HJManagedImageV, source can be found here: HJManagedImageV

[cell.imageV setImage:nil];

二传手

-(void)setImage:(UIImage *)theImage{
    if (theImage==image) {
        //when the same image is on the screen multiple times, an image that is alredy set might be set again with the same image.
        return; 
    }
    [theImage retain];
    [image release];
    image = theImage;
    [imageView removeFromSuperview];
    self.imageView = [[[UIImageView alloc] initWithImage:theImage] autorelease];
    [self addSubview:imageView];
    [imageView setNeedsLayout];
    [self setNeedsLayout];
    [loadingWheel stopAnimating];
    [loadingWheel removeFromSuperview];
    self.loadingWheel = nil;
    self.hidden=NO;
    if (image!=nil) {
        [callbackOnSetImage managedImageSet:self];
    }
}

我有一个解决方法,可以将imageV设置为hidden,但是我丢失了加载微调器,我真的很想知道为什么将其设置为nil无法正常工作.

I have a workaround for by setting imageV to hidden but then I lose the loading spinner and I'd really like to know why setting it to nil isn't working.

任何人都有任何主意,因为我全神贯注.还是我在某个地方错过了一步?

Anyone have any ideas, cause I'm all out of them. Or am I missing a step somewhere.

推荐答案

不要将其设置为nil,也不要将其隐藏.我们使用类似的类,在这种情况下,我们要做的是设置要显示的起始图像,直到加载新图像为止.因此,在您的情况下,您可以将捆绑包内的图片设置为空白jpg/png而不是nil

Don't set it to nil, nor hide it. We use a similar class and what we do for such cases is to set a start image to be displayed until the new image loads. So in your case you could simply set the image as a blank jpg/png inside your bundle instead of nil

这篇关于无法从ImageVIew中清除TableView中重用单元格中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆