iOS-web网络请求

1.ios7后新特性要求App内访问网络请求,要采用 HTTPS 协议,针对http须要在info.plist中进行以下配置ios

  • 在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];//加载
相关文章
相关标签/搜索