Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从cellForItemAtIndexPath中重新加载UICollectionViewCell_Ios_Uicollectionview_Uicollectionviewcell_Sdwebimage_Uicollectionreusableview - Fatal编程技术网

Ios 从cellForItemAtIndexPath中重新加载UICollectionViewCell

Ios 从cellForItemAtIndexPath中重新加载UICollectionViewCell,ios,uicollectionview,uicollectionviewcell,sdwebimage,uicollectionreusableview,Ios,Uicollectionview,Uicollectionviewcell,Sdwebimage,Uicollectionreusableview,在cellForItemAtIndexPath中重试失败的映像下载的最佳方法是什么?我有一个集合视图,可以显示大约20个80x80缩略图。我使用cellForItemAtIndexPath方法下载和缓存图像,但我发现图像常常无法下载。我知道我可以使用完成块测试图像是否为零,但它似乎没有正确地重新加载图像(图像仍然不会显示)。我应该这样处理重新装入电池的问题吗?下面是我的代码示例 - (UICollectionViewCell *)collectionView:(UICollectionView

在cellForItemAtIndexPath中重试失败的映像下载的最佳方法是什么?我有一个集合视图,可以显示大约20个80x80缩略图。我使用cellForItemAtIndexPath方法下载和缓存图像,但我发现图像常常无法下载。我知道我可以使用完成块测试图像是否为零,但它似乎没有正确地重新加载图像(图像仍然不会显示)。我应该这样处理重新装入电池的问题吗?下面是我的代码示例

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {   
    NSURL *thumbnailURL = [NSURL URLWithString:url];

    INCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];

    [cell.imageView setImageWithURL:thumbnailURL completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
        if (!image) {
            [self.collectionView reloadItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
        }
    }];

    return cell;
}
有答案吗

您需要使用带有“options”参数和 指定SDWebImageRetryFailed,如下所示

[cell.imageView setImageWithURL:thumbnailURL占位符图像:[UIImage] ImageName:@“placeholder.png”]选项:SDWebImageRetryFailed 已完成:^(UIImage*图像,NSError*错误,SDImageCacheType cacheType){…}]