美文网首页
SDWebImage

SDWebImage

作者: Run_4729 | 来源:发表于2018-08-19 15:29 被阅读0次

基础使用方式


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    cell.textLabel.text = @"sdsds";
    [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://cache.17c.cn/mobile/vip/ipadoff60.png"] placeholderImage:[UIImage imageNamed:@"dsdsd"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        NSLog(@"图片加载完成后做的事情");
    }];
    return cell;
}

然后图一直出不来,看了下报错信息

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

这是因为在iOS9中,苹果要求APP访问网络时必须使用HTTPS协议,这是一种使用了SSL加密的网络传输协议,使数据传输时更加安全。现在还是有很多公司在使用HTTP,而没有使用HTTPS,那我们就要支持HTTP协议。
打开我们的Xcode工程,找到info.plist文件并点击

解决方法

在Info.plist中添加 App Transport Security Settings 类型 Dictionary ;
并在App Transport Security Settings 下添加 Allow Arbitrary Loads 类型Boolean, 值设为 YES

相关文章

网友评论

      本文标题:SDWebImage

      本文链接:https://www.haomeiwen.com/subject/fvmciftx.html