我試圖使用AFNetworking使用此代碼本地URL獲得的圖像:AFNetworking和本地圖像URL
NSString *path = [DOCUMENTS stringByAppendingPathComponent:[NSString stringWithString:@"My Image.png"]];
[cell.imageView setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:path]] placeholderImage:[UIImage imageNamed:@"Placeholder Image.png"] success:nil failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"%s: setImageWithURLRequest error: %@", __FUNCTION__, error);
}];
和我收到此錯誤:
NSErrorFailingURLKey=/var/mobile/Applications/6D878789-640E-4299-AA72-45D49211492D/Documents/My Image.png, NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x15df8b60 "unsupported URL"}
我怎麼能用AFNetworking做到這一點?
只是一個想法。你試過* [NSURL fileURLWithPath:path] *方法嗎? – EmptyStack
NSURL * url = [NSURL fileURLWithPath:path]; [cell.imageView setImageWithUrl:url]; –