[cell.imageView setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"Icon.png"] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {

        NSLog(@"%@",error);

    }];

无法显示请求图片,只显示placeholderImage图片;


原因:iOS9以后,http协议改成了https协议,所以不能直接在http协议下GET/POST

解决方法1:直接在工程info.plist文件下添加代码
  

<key>NSAppTransportSecurity</key>

<dict>

<key>NSAllowsArbitraryLoads</key>

        <true/>

    </dict>

如图:
SDWebImage 加载图片不显示问题

解决方法2:
在代码行,使用字符串替换,

NSString * str1 = @“http”

NSString * str2=[str1 stringByReplacingOccurrencesOfString:@"http" withString:@"https"];





相关文章: