在 UIWebView 中加载 HTTPS url [英] Load HTTPS url in a UIWebView

查看:31
本文介绍了在 UIWebView 中加载 HTTPS url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用 iPhone 编程,但遇到了无法解决的大问题.

I begin iPhone programming and I have big problem I cant resolve.

所以,我有一个 UIWebview,我可以毫无问题地加载 HTTP 网址:

So, I have a UIWebview, I can load HTTP url without problems :

NSString urlAdress;
urlAdress = @"http://servername";
NSURL *url = [NSURL URLWithString:urlAdress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];

它的工作,我的页面在我的 UIwebView 中加载,但是当我替换时:

Its work, my page is load in my UIwebView, but when I replace :

urlAdress = @"http://servername";

urlAdress = @"https://servername";

我有空白屏幕.

我读的很正常,但是有没有简单的方法可以在我的 webview 中加载 https url?
我阅读了关于 ASIHTTPRequest 的内容,但我没有来实现它.

I read its normal, but is there easy method to load https url in my webview ?
I read about ASIHTTPRequest but I didnt arrive to implement it.

我只想加载HTTPS URL.

推荐答案

试试这个:

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
    return YES;
}


- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
    [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
}

这篇关于在 UIWebView 中加载 HTTPS url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆