SDWebImage

基础使用方式


- (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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容