繁体   English   中英

想知道使用SDWebImage在URL处图像是否不可用

[英]want to know if the image is not available at url using SDWebImage

在我的应用程序中,我正在使用SDWebImage库从Web服务的url下载图像。 我没有这个代码的问题

[imgQuestionContainer sd_setImageWithURL:[NSURL URLWithString:@"url"] placeholderImage:@"abc.png" options:SDWebImageProgressiveDownload];

使用上面的代码,我已经成功将图像加载到imageview中...

但是我的问题是,如果我有图片的网址,但是该网址的特定路径处没有图片。 因此,如何知道该图像不可用,以便我可以加载下一个数据。

谢谢。

[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
               placeholderImage:[UIImage imageNamed:@"placeholder.png"]
                        success:^(UIImage *image) {
                                       if(image){

                                       }else{

                                            }
}
                        failure:^(NSError *error) {
                                      }];
];

这正是我想要的。

[imgQuestionContainer sd_setImageWithURL:[NSURL URLWithString:[[arrOfLoadedPuzzel objectAtIndex:0] objectForKey:@"puzzle_question"]]
                  placeholderImage:nil
                         completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL)
                        {
                            if(error)
                            {
                                 // image is not available
                            }
                            else
                            {
                                 // image is available
                            }
                       }];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM