ios - 没有 ssl 证书的 SDWebImage
问题描述
我尝试通过 SDWebImage 设置图像。但 SDWebImage 取消操作。我试图在 Safari 中使用 url 获取此图像,而 Safari 向我询问了证书。当我取消对话窗口时,我得到了这个图像。
问题是:我可以在不修改此库的情况下禁用 SDWebImage 证书验证吗?
解决方案
我花了很多时间钻研 SDWebImage 代码并找到解决方案。我想知道为什么文档没有明确说明如何做到这一点!
这是示例代码:
NSURL *url = ... <image url here>
UIImageView *imageView = ...
[imageView sd_setImageWithURL:url placeholderImage:nil options:SDWebImageAllowInvalidSSLCertificates progress:^(NSInteger receivedSize, NSInteger expectedSize) {
CGFloat percentage = ((CGFloat)receivedSize)/((CGFloat)expectedSize);
//Track progress here if needed.
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
...
}];
关键时刻是通过SDWebImageAllowInvalidSSLCertificates
期权。在内部,此选项将转换为共享图像下载器的正确选项。
希望这会有所帮助,并希望下次我再次面对这个问题时能够找到我的答案!
推荐阅读
- amazon-web-services - 查询 DynamoDB 时出现空响应
- java - 将字符串转换为int数组后如何正确减去从字符串中取出的2个数字
- php - 我怎样才能在这里避免嵌套循环?使用 php
- angular - 当firebase中的数据发生变化时如何更新快照的本地副本?
- flutter - 如何删除颤振模拟器
- linux - Why Contiguous memory allocation is required in linux?
- r - 将字符 YYYY-MM-00 转换为 R 中的日期 YYYY-MM
- python - LaunchDarkly 带有 celery 的功能标志
- php - MySQL 查询特定客户及其交易详情
- c++ - 如何在数组中获取特定的用户输入?