2016-09-10 2 views
0

Я использовал UIWebview для подключения accounts.craigslist.org , но это не сработает. Если я сменил адрес сайта на google www.google.com он работает. Я использую прокси, но я не думаю, что это проблема прокси. код нижеiPhone UIWebView Не могу подключиться Некоторые сайты


self.mWebView.delegate = self; 

NSURL *url = [NSURL URLWithString:urlString]; 
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageAllowed timeoutInterval:15.0]; 
    [self.mWebView loadRequest:urlRequest]; 

Вот pInfo.list screenshot (я видел какое-то решение, но не работает для меня с этого сайта)

И я применил другие решения с 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

+0

Вы можете разделить строку кода, где вы принимаете строку URL? – Janmenjaya

ответ

0

попробовать это один

NSString *[email protected]"accounts.craigslist.org"; 
NSString *str=[NSString stringWithFormat:@"%@",Url]; 
NSURL *urls=[[NSURL alloc]initWithString:str]; 

[_webView loadRequest:[NSURLRequest requestWithURL:urls]]; 
Смежные вопросы