来自foursquare的图像是NSURLErrorFileDoesNotExist = -1100 [英] images from foursquare are NSURLErrorFileDoesNotExist = -1100

查看:119
本文介绍了来自foursquare的图像是NSURLErrorFileDoesNotExist = -1100的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从foursquare下载图像(源自使用场馆api),并且不断收到NSURLErrorFileDoesNotExist = -1100,这是尝试获取图像的错误.

I am attempting to download an image from foursquare( sourced from using the venue api) and I keep getting NSURLErrorFileDoesNotExist = -1100, errors for trying to grab the image.

imageUrl = [NSURL URLWithString: [NSString stringWithFormat:
                                  [@"https://irs0.4sqi.net/img/general/720x400/1203715_jAVNrPE87IFuOUa69i1q5UXQ0bUAfjG8V-R_hBUL09c.jpg" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
//[cell.venueImageView sd_setImageWithURL:imageUrl placeholderImage:nil];
typeof(WHMDateListTableViewCell *) __weak weakCell = cell;
[cell.venueImageView sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"create-profile-step-4-pic-box-reg"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
    weakCell.venueImageView.image = image;
}];

图片网址在Chrome中可以正常加载.我还从其他网址中提取了其他图片,效果很好.

The image url loads fine in Chrome. I have also pulled other images from other web urls and it works fine.

推荐答案

问题是API正在使用https方案返回图像.一旦我将返回的URL设置为http而不是https的URL,便可以正确下载该图像以供imageview显示.

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.

//setup Venue
NSURL *imageUrl;

imageUrl = [NSURL URLWithString:self.selectedDate.Venue.Media[indexPath.item]];

NSURLComponents *components = [NSURLComponents new];
components.scheme = @"http";
components.host = imageUrl.host;
components.path = imageUrl.path;

NSURL *url = [components URL];


[cell.photoImageView sd_setImageWithURL:url placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
    ;
}];

这篇关于来自foursquare的图像是NSURLErrorFileDoesNotExist = -1100的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆