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];//加載
相關文章
相關標籤/搜索