我正在尝试下面的代码,但它给出了错误:
{
NSURL *url = [NSURL URLWithString:@"http://ielmo.xtreemhost.com/array.php"];
NSURLRequest *urlRequest =[[NSURLRequest alloc]initWithURL:url];
AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];
requestOperation.responseSerializer = [AFImageResponseSerializer serializer];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Response: %@", responseObject);
_imV.image = responseObject;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Image error: %@", error);
}];
[requestOperation start];
}
请帮助我
"Request failed: unacceptable content-type: text/html"
错误。 最佳答案
请尝试以下代码:
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
关于ios - 使用AFNetworking 2.0的“请求失败: Not Acceptable 内容类型:text/html”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26756258/