簡體   English   中英

無法從ImageVIew中清除TableView中重用單元格中的圖像

[英]Image in reused cell in a TableView not being cleared from ImageVIew

我有一個包含帶圖像的單元格的Tableview,但是被重用的單元格仍然包含來自被重用的前一個單元格的圖像,直到下載並設置新圖像為止。

我嘗試將圖像設置為nil。 (imageV是HJManagedImageV的子類,可在此處找到源: 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不能正常工作。

任何人都有任何想法,因為我全神貫注。 還是我在某個地方錯過了一步。

單元格是UITableViewCell的子類嗎? 如果是,我將嘗試實現方法prepareForReuse ,看看是否可以解決那里的問題。

希望這可以幫助=)

不要將其設置為nil,也不要將其隱藏。 我們使用類似的類,在這種情況下,我們要做的是設置要顯示的起始圖像,直到加載新圖像為止。 因此,在您的情況下,您可以將捆綁包內的圖片設置為空白jpg / png而不是nil

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM