Xcode 7 ATS设置
2015-10-29 14:27
316 查看
这两天研究SDWebimage库,在xode 7上运行过程中遇到了些问题,创建的新项目由于使用到了https的图片URL,运行后,怎么都不出现图片,发送请求时,报下面的错:
“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”
经过搜索stackoverflow查询相关问题发现,iOS9新特性要求App内访问网络请求要采用HTTPS协议,无论url是http的还是https的。通过进行如下设置即可:
然后尝试了SDWebimage不同的图片加载方法,均成功展示。后面可以正常研究图片缓存的实现了。
“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”
经过搜索stackoverflow查询相关问题发现,iOS9新特性要求App内访问网络请求要采用HTTPS协议,无论url是http的还是https的。通过进行如下设置即可:
在Info.plist中添加 NSAppTransportSecurity 类型 Dictionary ; 在 NSAppTransportSecurity 下添加 NSAllowsArbitraryLoads 类型Boolean ,值设为 YES; |
/** * Using SDWebimage */ NSURL *imgURL = [NSURL URLWithString:@"http://www.sogou.com/images/logo/new/sogou.png"]; // Using UIImageView+WebCache category [imageView sd_setImageWithURL:imgURL placeholderImage:[UIImage imageNamed:@"default_pic"]]; // Using blocks [imageView sd_setImageWithURL:imgURL placeholderImage:[UIImage imageNamed:@"default_pic"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { }]; // Using SDWebImageManager SDWebImageManager *manager = [SDWebImageManager sharedManager]; [manager downloadImageWithURL:imgURL options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) { // progression tracking code } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { if (image) { // do something with image [imageView setImage:image]; } }]; // Using Asynchronous Image Downloader Independently SDWebImageDownloader *downloader = [SDWebImageDownloader sharedDownloader]; [downloader downloadImageWithURL:imgURL options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) { // progression tracking code } completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) { if (image && finished) { // do something with image [imageView setImage:image]; } }]; |
相关文章推荐
- js倒计时
- [转]iOS开发总结之代码规范
- GitHub秘籍
- java读取配置文件中的每一行并遍历
- UIApplication
- 横竖屏切换时候Activity的生命周期
- java性能优化的地方
- nginx配置详解
- 11.线性表之单链表的基本操作
- TRUNC函数,ORA-01898 精度说明符过多
- 线上应用故障排查之一:高CPU占用
- 【Mockplus教程】删除
- Android平台下利用zxing实现二维码开发
- MySQL备份方案(综述及脚本)
- 横竖屏切换时候Activity的生命周期
- Maven搭建hadoop环境报Missing artifact jdk.tools:jdk.tools:jar:1.8
- Exception in thread "main" java.lang.Error: Unresolved compilation problem
- JS原型与原型链终极详解(推荐阅读)
- c编程之代码优化总结
- linux服务器和windows服务器中svn服务器的搭建【仅供参考】