2016-08-27 11 views
0

tableViewがあります。配列(cellMap)からデータを取り出しています。 viewDidLoadでは、データが配列に追加されています。背景をイメージにロード

CellModel *model = self.cellMap[indexPath.row]; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:configurator.identifier forIndexPath:indexPath]; 

cell.title = model.title; 
cell.price = model.price; 
cell.image = model.image; 

return cell; 

法画像負荷のためにバックグラウンドで:データがアレイから取得されcellForRowAtIndexPath方法において

[self.cellMap addObject:[CellModel initWithTitle:title 
              price:price 
              image:getProductImageByImgURL:url 
]; 

- (UIImage *)getProductImageByImgURL:(NSString *)url { 
    __weak typeof(self)weakSelf = self; 
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 
     __strong typeof(self)strongSelf = weakSelf; 

     strongSelf.productImage = [UIImage loadImage:url]; 
    }); 
    return self.productImage; 
} 

どこself.productImage@property (strong, nonatomic) UIImage *productImage;

結果です - すべてのセルに最後にロードされたイメージがあります。何が問題ですか?

答えて

0

私はあなたが一時変数を使用しようとすることができ

strongSelf.productImage = [UIImage loadImage:url]; 

、あなたの問題は、この結果からだと思います。そして、それを作る、

UIImage * tempImage = [UIImage loadImage:url]; 
+0

Not working .. 8( – Gikas

関連する問題