1.ios7后新特性要求App内访问网络请求,要采用 HTTPS 协议,针对http需要在info.plist中进行如下配置
- 在Info.plist中添加 App Transport Security Settings 类型 Dictionary ;
- 在 App Transport Security Settings 下添加 Allow Arbitrary Loads 类型Boolean ,值设为 YES;
UIWebView *webView=[[UIWebView alloc] initWithFrame:CGRectMake(0.0f,0.0f,self.view.bounds.size.width,self.view.bounds.size.height)];
[self.view addSubview:webView];
NSURL* url = [NSURL URLWithString:@"http://www.baidu.com"];//创建URL
NSURLRequest* request = [NSURLRequest requestWithURL:url];//创建NSURLRequest
[webView loadRequest:request];//加载