我刚刚更改了我的代码,将图像从EGOImageCache缓存到SDWebView。不幸的是,我不知道如何设置自定义HTTP标头,因为我必须发送认证才能获取图像。使用EGOImageCache很容易,因为我已将NSURLRequest扩展到适当的位置。但我不知道如何用SDWebView.framework来做到这一点。我看到标题,我发现SDWebImageDownloader.h中的方法包含SDWebImage并设置自定义HTTP标头?
/**
* Set a value for a HTTP header to be appended to each download HTTP request.
*
* @param value The value for the header field. Use `nil` value to remove the header.
* @param field The name of the header field to set.
*/
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;
/**
* Returns the value of the specified HTTP header field.
*
* @return The value associated with the header field field, or `nil` if there is no corresponding header field.
*/
- (NSString *)valueForHTTPHeaderField:(NSString *)field;
似乎lib确实支持HTTP标头。但是,因为我使用UIImageView + WebCache.h我不能看到有设置标题的选项。在我的代码我打电话
[self.imageView setImageWithURL:[NSURL URLWithString:themeImageURL] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
有人可以告诉我如何设置HTTP标头?
我会试试看。谢谢您的回复!似乎并不是很多开发者需要这个功能。 – rockstarberlin 2013-05-27 15:21:20
你先生应该得到更多的赞扬。这个答案是100%正确的,原始代码是直观的。 – Emilio 2014-04-23 14:06:26
为什么,上帝?为什么这个SDK以这种方式工作?为什么? – d512 2014-05-07 19:30:19