Xcode版升级为7.0时,原来版本的工程图片数据请求需要设置
2015-10-06 00:37
337 查看
一、
在XCODE版升级为7.0了
就要在 :1、工程中的 Info.plist中添加 NSAppTransportSecurity 其类型为Dictionary。
2、在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,其值设为YES
二、请求图片数据时可将 方法viewDidLoad1 以 方法 viewDidLoad2 代替
- (void)viewDidLoad1 {
[superviewDidLoad];
self.view.backgroundColor = [UIColorgrayColor];
NSURL *url = [NSURLURLWithString:@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=903634168,884117676&fm=116&gp=0.jpg"];
NSURLRequest *request = [NSURLRequestrequestWithURL:url];
NSURLResponse *response;
NSData *data =[NSURLConnectionsendSynchronousRequest:requestreturningResponse:&responseerror:nil];
UIImageView *imagv = [[UIImageViewalloc]initWithFrame:CGRectMake(100,200,100,
100)];
imagv.backgroundColor = [UIColorredColor];
imagv.image = [UIImageimageWithData:data];
[self.viewaddSubview:imagv];
改为一下
- (void)viewDidLoad2 {
// NSURLRequest *request1 = [NSURLRequest requestWithURL:URL];
//
// NSURLSession *session = [NSURLSession sharedSession];
//
// NSURLSessionDataTask *task = [session dataTaskWithRequest:request1
// completionHandler:
// ^(NSData *data, NSURLResponse *response, NSError *error) {
// UIImageView *imagv = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
// imagv.backgroundColor = [UIColor redColor];
// [self.view addSubview:imagv];
// imagv.image = [UIImage imageWithData:data];
//
4000
NSLog(@"------%@",imagv.image);
// }];
//
// [task resume];
}
在XCODE版升级为7.0了
就要在 :1、工程中的 Info.plist中添加 NSAppTransportSecurity 其类型为Dictionary。
2、在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,其值设为YES
二、请求图片数据时可将 方法viewDidLoad1 以 方法 viewDidLoad2 代替
- (void)viewDidLoad1 {
[superviewDidLoad];
self.view.backgroundColor = [UIColorgrayColor];
NSURL *url = [NSURLURLWithString:@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=903634168,884117676&fm=116&gp=0.jpg"];
NSURLRequest *request = [NSURLRequestrequestWithURL:url];
NSURLResponse *response;
NSData *data =[NSURLConnectionsendSynchronousRequest:requestreturningResponse:&responseerror:nil];
UIImageView *imagv = [[UIImageViewalloc]initWithFrame:CGRectMake(100,200,100,
100)];
imagv.backgroundColor = [UIColorredColor];
imagv.image = [UIImageimageWithData:data];
[self.viewaddSubview:imagv];
改为一下
- (void)viewDidLoad2 {
// NSURLRequest *request1 = [NSURLRequest requestWithURL:URL];
//
// NSURLSession *session = [NSURLSession sharedSession];
//
// NSURLSessionDataTask *task = [session dataTaskWithRequest:request1
// completionHandler:
// ^(NSData *data, NSURLResponse *response, NSError *error) {
// UIImageView *imagv = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
// imagv.backgroundColor = [UIColor redColor];
// [self.view addSubview:imagv];
// imagv.image = [UIImage imageWithData:data];
//
4000
NSLog(@"------%@",imagv.image);
// }];
//
// [task resume];
}
相关文章推荐
- poj2965
- 数据结构: Java中LinkedList的简单实现
- Sublime Text插件怎么安装
- n皇后问题
- 使用系统提供的AVFoundation 实现二维码扫描(带动画)
- 数据结构: Java中ArrayList的简单实现
- n皇后问题
- 【求组合数模板】
- Mac OS X 10.10 Yosemite安装windows和禁止访问详解
- LINQ之路(2):LINQ to SQL本质
- hdoj 1022 Train Problem I
- poj 2778(ac自动机+矩阵快速幂)
- 深入理解Javascript之this关键字
- windows内核对象
- UVa 610
- 条件语句
- [codeforces 582b]Once Again…
- [codeforces 580D]Kefa and Dishes
- Docker学习总结之Run命令介绍
- Codeforces Round #323 (Div. 2)C. GCD Table