2016-08-01 356 views
0

當我將網站加載到我的可可應用程序的webview中時出現此問題。 我的問題描述:如何處理「太多的HTTP重定向」錯誤

錯誤域= NSURLErrorDomain代碼= -1007 「HTTP重定向過多」 的UserInfo = {0x18d17d56 = NSErrorFailingURLStringKey URLHERE, NSErrorFailingURLKey = URLHERE,NSLocalizedDescription =太多的HTTP重定向 }

爲什麼這個錯誤出現
如何處理呢

我走了,雖然下面的鏈接,但簡化版,幫我

Too many HTTP redirects
"too many HTTP redirects" while using Alamofire Upload Multipart Form Data
too many HTTP redirects, Google Drive, iOS SDK等等..

UPDATE:

- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource { 
    if(redirectResponse) 
    { 
     if([redirectResponse.URL.absoluteString isEqualToString:self.webviewLoadingURL.absoluteString]) 
     { 
      NSLog(@"both redirect and load url is same"); 
     } 
    } 
    return request; 
} 

我越來越對的WebView重定向和負載相同的URL。

回答

0

這幾乎總是由導致網頁重定向到自身(可能通過另一箇中間URL)的服務器配置錯誤引起的。除非問題是由您的客戶端代碼請求無效/不正確的URL導致的,否則您可能無法在客戶端修復此問題。

如果你問如何向用戶提出錯誤,我會說你應該像對待404一樣對待它。該URL不可能很快開始工作。