AFNetworking을 사용하여 다음과 같은 이미지를로드했습니다.
[thumbnailImage setImageWithURL:_item.thumbnailUrl];
그리고 그것은 잘 작동했습니다. 그러나 이제 우리는 작동이 중지 된 나머지 프로젝트를 가져 왔습니다. 배경색 만 보여주고있었습니다. 그래서 이것을 사용해 보았고 자리 표시자를로드하지만 이미지는로드하지 않습니다.
UIImage* placeholder = [UIImage imageNamed:@"placeholder"];
[thumbnailImage setImageWithURL:_item.thumbnailUrl placeholderImage:placeholder];
나는 문제가 무엇인지 볼 수 있다고 생각했기 때문에 시도했습니다.
NSURLRequest* urlRequest = [NSURLRequest requestWithURL:_item.thumbnailUrl cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30];
[thumbnailImage setImageWithURLRequest:urlRequest placeholderImage:[UIImage imageNamed:@"placeholder"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image)
{
NSLog(@"Loaded Image");
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error)
{
NSLog(@"Failed to load Image");
}];
예상하는 반환 유형을 얻지 못하는 것 같습니다. 그것은 말한다 Expected content type image/png, got binary/octet-stream
내가 유형을 제어 할 수 있다면 나도 몰라 그래서 아마존 S3에서 이미지를 당기는거야.
데이터 유형을 변경할 수 acceptableContentTypes
없어서 프로젝트에 다음 파일을 추가하여 AFNetworking 의 메서드를 재정의했습니다.
AFImageRequestOperation + OctetMIMEType.h
//
// AFImageRequestOperation+OctetMIMEType.h
// iQ.fileShare
//
// Created by Poole, Patrick on 4/25/13.
//
//
#import "AFImageRequestOperation.h"
@interface AFImageRequestOperation (OctetMIMEType)
@end
AFImageRequestOperation + OctetMIMEType.m
//
// AFImageRequestOperation+OctetMIMEType.m
// iQ.fileShare
//
// Created by Poole, Patrick on 4/25/13.
//
//
#import "AFImageRequestOperation+OctetMIMEType.h"
@implementation AFImageRequestOperation (OctetMIMEType)
+ (NSSet *)acceptableContentTypes {
return [NSSet setWithObjects:@"binary/octet-stream",@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon" @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil];
}
@end
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다