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

本文是小编为大家收集整理的关于来自foursquare的图片是NSURLErrorFileDoesNotExist = -1100的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我试图从foursquare下载图像(来自使用场地API),并且我一直在获得nsurlerrorfiledoesnotexist = -1100,试图抓取图像的错误.

.
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;
}];

图像URL在Chrome中加载罚款.我还从其他Web URL中摘下了其他图像,并且可以正常工作.

推荐答案

问题是API正在使用HTTPS方案返回图像.一旦我操纵返回的URL为HTTP,而不是HTTPS,那么我就可以正确下载图像视图显示.

//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) {
    ;
}];

本文地址:https://www.itbaoku.cn/post/2090878.html

问题描述

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;
}];

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

推荐答案

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) {
    ;
}];