作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我开始 iPhone 编程,但遇到了无法解决的大问题。
所以,我有一个 UIWebview
,我可以毫无问题地加载 HTTP url:
NSString urlAdress;
urlAdress = @"http://servername";
NSURL *url = [NSURL URLWithString:urlAdress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
它的工作,我的页面加载到我的 UIwebView 中,但是当我替换时:
urlAdress = @"http://servername";
通过
urlAdress = @"https://servername";
我有黑屏。
我看它是正常的,但是有没有简单的方法可以在我的 webview 中加载 https url?
我阅读了有关 ASIHTTPRequest
的内容,但我并没有去实现它。
我只想加载 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];
}
关于ios - 在 UIWebView 中加载 HTTPS url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6307400/
我是一名优秀的程序员,十分优秀!