iPhone UIWebView 无法连接某些站点
iPhone UIWebView Can't connect Some site
我已经使用UIWebview
连接
accounts.craigslist.org
但它不起作用。
如果我将站点地址更改为 google www.google.com
有用。
我正在使用代理,但我认为这不是代理问题。
下面的代码
self.mWebView.delegate = self;
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageAllowed timeoutInterval:15.0];
[self.mWebView loadRequest:urlRequest];
这里是 (我看到了一些解决方案,但在这个网站上对我不起作用)
并且我已经通过 NSURLConnectionDataDelegate
委托
应用了其他解决方案
- (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];
}
Error Output screenshot
试试这个
NSString *Url=@"accounts.craigslist.org";
NSString *str=[NSString stringWithFormat:@"%@",Url];
NSURL *urls=[[NSURL alloc]initWithString:str];
[_webView loadRequest:[NSURLRequest requestWithURL:urls]];
我已经使用UIWebview
连接
accounts.craigslist.org
但它不起作用。
如果我将站点地址更改为 google www.google.com
有用。
我正在使用代理,但我认为这不是代理问题。
下面的代码
self.mWebView.delegate = self;
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageAllowed timeoutInterval:15.0];
[self.mWebView loadRequest:urlRequest];
这里是
并且我已经通过 NSURLConnectionDataDelegate
委托
- (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];
}
Error Output screenshot
试试这个
NSString *Url=@"accounts.craigslist.org";
NSString *str=[NSString stringWithFormat:@"%@",Url];
NSURL *urls=[[NSURL alloc]initWithString:str];
[_webView loadRequest:[NSURLRequest requestWithURL:urls]];