有些图片路径在浏览器上第一次没出来第二次出来的情况,或者浏览器上出来,本机上出现错误
网络无法链接【404】
网络无法链接【-1100】
解决办法
1
The issue was that the API was returning images with an https scheme. Once I manipulated the returned URL to be of http, instead of https then I was able to properly download the image for imageview display.
// NSURLComponents *components = [NSURLComponents new];
// components.scheme = @"http";
// components.host = imageUrl.host;
// components.path = imageUrl.path;
//
// NSURL *url = [components URL];
2
[_imageViewHead sd_setImageWithURL:[NSURL URLWithString:item.strImageUrl] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
if (error) {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
UIImage *imagea = [UIImage imageWithData: [NSData dataWithContentsOfURL:imageURL]];
dispatch_async(dispatch_get_main_queue(), ^{
_imageViewHead.image = imagea;
});
});
}
}];