Iphone 为什么某些Https url没有加载到WebView中?

Iphone 为什么某些Https url没有加载到WebView中?,iphone,ios,xcode,cocoa-touch,uiwebview,Iphone,Ios,Xcode,Cocoa Touch,Uiwebview,为什么一些https链接没有加载WebView。我可以看到一些https url在safari浏览器中加载得非常完美,但是当我尝试在webview中加载相同的url时,它没有加载。可能是因为https具有自签名证书??我们不能在WebView中加载具有自签名证书的url吗 编辑: 现在我可以打电话了 - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtec

为什么一些https链接没有加载WebView。我可以看到一些https url在safari浏览器中加载得非常完美,但是当我尝试在webview中加载相同的url时,它没有加载。可能是因为https具有自签名证书??我们不能在WebView中加载具有自签名证书的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];
}
我的https url仍然没有加载到WebView中。

请尝试以下操作:

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

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
NSArray *trustedHosts = [NSArray arrayWithObjects:@"mytrustedhost",nil];

if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]){
    if ([trustedHosts containsObject:challenge.protectionSpace.host]) {
    [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
    }
}
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}

我应该在.h文件中添加NSURLConnectionLegate吗。到目前为止,在.h文件UIViewController中添加了.Add-in.m文件。如果我在.m文件中添加了这两个方法,请告诉我是否有任何问题。我保留了断点,它没有被调用(我正在使用以下代码处理请求,NSURL*urlink=[NSURL URLWithString:url];NSURLRequest*request=[nsurlRequestWithURL:urlink];[self.webView loadRequest:request];请再次检查我的问题,我已经按照您所说的更新了我的代码。等待您的答复。)