我试图通过SDWebImage设置图像。但SDWebImage取消了操作。我尝试用url和Safari在Safari中获取这个图像,Safari问我关于证书的问题。当我取消对话框窗口时,我会得到这个图像。
问题是:我可以在不修改库的情况下禁用SDWebImage证书验证吗?
发布于 2018-10-04 06:19:57
我花了很多时间钻研SDWebImage代码并找到解决方案。我想知道为什么docs没有明确地说明如何做到这一点!
下面是示例代码:
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
选项。在内部,此选项将被转换为共享图像下载机的适当选项。
希望这会有所帮助,并希望下次我再次面对这个问题时能找到我的答案!
发布于 2019-01-01 10:25:52
使用
UIImageView_name.sd_setImage(with: URL(string: logo), placeholderImage: nil, options: .allowInvalidSSLCertificates)
而不是
UIImageView_name.sd_setImage(with: URL(string: logo))
UIImageView_name
用于UIButton
UIButton_name.sd_setImage(with: URL(string: customer.getProfilePic()), for: .normal, placeholderImage: nil, options: .allowInvalidSSLCertificates, completed: nil)
https://stackoverflow.com/questions/50043324
复制相似问题