Load HTTPS url in a UIWebView

戏子无情 提交于 2019-11-29 14:18:49

问题


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

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];

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

urlAdress = @"http://servername";

by

urlAdress = @"https://servername";

I have blank screen.

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.

I just want to load HTTPS URL.


回答1:


Try this :

- (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];
}


来源:https://stackoverflow.com/questions/6307400/load-https-url-in-a-uiwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!