iOS9.3 xcode7.3.1我想使用WebView访问HTTPS站点,出现错误(kCFStreamErrorDomainSSL,-9843)
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://52.197.95.84/ResonaIgonWeb/index.html"]];
request.allowsCellularAccess = YES;
request.timeoutInterval = 7.0;
self.myWebview.delegate = self;
self.myWebview.scrollView.showsHorizontalScrollIndicator = NO;
self.myWebview.scrollView.showsVerticalScrollIndicator = NO;
self.myWebview.scrollView.backgroundColor = [UIColor whiteColor];
[self.myWebview loadRequest:request];
当我意识到代理
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString* str = request.URL.scheme;
if ([str isEqualToString:@"https"]) {
if (isOK == NO) {
originrequest = request;
NSURLSessionConfiguration* con = [NSURLSessionConfiguration defaultSessionConfiguration];
con.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
NSURLSession* urlsession = [NSURLSession sessionWithConfiguration:con delegate:self delegateQueue:[NSOperationQueue mainQueue]];
task = [urlsession dataTaskWithRequest:request completionHandler:^(NSData* _Nullable data, NSURLResponse* _Nullable response, NSError* _Nullable error) {
NSString* str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", str);
}];
[task resume];
[webView stopLoading];
return NO;
}
}
return YES;
}
我已经在info.list中添加了
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
有什么方法可以使用HTML在服务器上显示XX WebView?请帮帮我!
试试这个
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>insecure.example.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句