错误情况
NSURL* url = [NSURL URLWithString:_loginModel.data[@"face"]];
[cell.topImageView sd_setImageWithURL:url placeholderImage:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
NSLog(@"%@", error);
}];
这里使用SDWebImage获取自己上传到数据库中的头像,然后无法显示,打印了一下error: Error Domain=NSURLErrorDomain Code=-1202 “The certificate for this server is invalid. You might be connecting to a server that is pretending to be “cpblog.vip” which could put your confidential information at risk.” 这里的意思就是访问了一个没有证书的私人网站。 打印了一下url :
https:
发现在浏览器是可以访问的,只不过会提示危险,所以我们把url里面的https改成http就可以正常显示了。
NSMutableString* testString1 = [_loginModel.data[@"face"] mutableCopy];
[testString1 replaceCharactersInRange:NSMakeRange(0, 5) withString:@"http"];
NSURL* url = [NSURL URLWithString:testString1];
[cell.topImageView sd_setImageWithURL:url placeholderImage:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
NSLog(@"%@", error);
}];
|