Iphone UITableViewCell无条件

Iphone UITableViewCell无条件,iphone,uitableview,Iphone,Uitableview,通常我们在Cell nil条件之外配置Cell。在我的例子中,我正在做同样的事情,将NSData转换为单元格nil之外的图像。所以,每次我启动请求并重新加载表时,它都会将特定单元格的数据完美地转换为图像。但在重新加载表之后,我的问题是,当我滚动表时,每次它都会将NSData转换为图像,这是显而易见的。我需要避免在重新加载表后滚动时进行这种转换 static NSString *CellIdentifierImage = @"CellIdentifierImage"; if(indexP

通常我们在Cell nil条件之外配置Cell。在我的例子中,我正在做同样的事情,将NSData转换为单元格nil之外的图像。所以,每次我启动请求并重新加载表时,它都会将特定单元格的数据完美地转换为图像。但在重新加载表之后,我的问题是,当我滚动表时,每次它都会将NSData转换为图像,这是显而易见的。我需要避免在重新加载表后滚动时进行这种转换

    static NSString *CellIdentifierImage =  @"CellIdentifierImage";
if(indexPath.section == 0)
    {
        NewsImageCell *newsImageCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierImage];

        if (newsImageCell == nil)
        {
            NSLog(@"CellNil");
            newsImageCell = [[NewsImageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifierImage];
            newsImageCell.selectionStyle = UITableViewCellSelectionStyleNone;
        }

        if([[ApplicationData sharedInstance].arrTop10NewsHome count]>0)
        {
            NSMutableDictionary *dicSource = [arrSource objectAtIndex:indexPath.row];
            NSURL *urlImage = [NSURL URLWithString:[dicSource retrieveForPath:@"ItemImage"]];
            newsImageCell.lblNewsHeading.text = [dicSource objectForKey:@"Title"];
            [newsImageCell.loadingIndicator startAnimating];
            dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
            dispatch_async(queue, ^{
                UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:urlImage]];
                dispatch_sync(dispatch_get_main_queue(), ^{
                    newsImageCell.imgVwNews.image = image;
                    [newsImageCell.loadingIndicator stopAnimating];
                });
            });
        }

        return newsImageCell;
    }
欣赏你的想法 提前感谢

使用而不是UIImageView

请参阅的演示项目,您可以使用HJCache 这可能最适合这种情况