簡體   English   中英

SDWebImage拇指+原始圖像加載問題

[英]SDWebImage thumb + original image loading issue

我正在嘗試先加載縮略圖,然后請求圖像的原始版本,但未獲得對原始圖像請求的響應。

[imageView sd_setImageWithURL:thumbUrl completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {

    if (image) {

        imageView.image = image;

        if (originalUrl != nil) {

            [imageView sd_setImageWithURL:originalUrl placeholderImage:image completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL){

                if (image) {

                    imageView.image = image;
                }

            }];
        }
    }
}];

謝謝 ..

試試這種情況

[imageView sd_setImageWithURL:thumbUrl completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        if (originalUrl != nil) {
            [imageView sd_setImageWithURL:originalUrl placeholderImage:image completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL){
            }];
        }
    }
}];

這個:

[[SDWebImageManager sharedManager] downloadImageWithURL:[NSURL URLWithString:path]
                                                        options:nil
                                                       progress:nil
                                                      completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
                                                          if (image)
                                                          {
                                                              [self.artworkImageView sd_setImageWithURL:[NSURL URLWithString:path2] placeholderImage:image
                                                                                              completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
                                                                                                  if (image)
                                                                                                      NSLog(@"magic");
                                                                                              }];
                                                          }
                                                      }];

我用以下代碼解決了我的問題

UIImageView * hiddenImageView = [[UIImageView alloc] init];

[hiddenImageView sd_setImageWithURL:thumbUrl completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {

    if (image) {

        mImageView.image = image;
    }

    if (originalUrl != nil) {

        [mImageView sd_setImageWithURL:originalUrl placeholderImage:image completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL){

            if (image) {

                mImageView.image = image; // optional
            }

        }];

    }
}];

暫無
暫無

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

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