3

Apple の UIWebViewDelegate に記載されていないこの動作が見られます。

デリゲート関数に NO を返すと

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

この関数は、すぐにエラー 101 (この URL を読み込めません) で呼び出されます。

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {

明示的にリクエストをキャンセルしたので、didFailLoadWithError が呼び出されるのは正常ですか?

4

2 に答える 2

0

Web ビューがコンテンツの読み込みを開始する必要がある場合は、常にnoshouldStartLoadWithRequest を返す必要があります。YESそうでなければ、いいえ

接続にエラー 101 (net::ERR_CONNECTION_RESET): 不明なエラーがある場合は、次のような問題が発生している可能性があります。

You are trying to connect to the internet but the pages won’t load.
You are trying to refresh/reload the page so many times but to no avail.
You can see a lot of weird stuff all over the page. (links and images are unaligned.)
When the page doesn’t load, you can see the phrase “Error 101 (net::ERR_CONNECTION_RESET): Unknown error”.

デリゲートへのリクエストを常に処理し、NO を返す必要があります。次に、NSURLConnection から受信した応答呼び出しで接続をキャンセルし、すべてが正常であれば (応答を確認して)、webview にもう一度 urlrequest をロードします。urlrequest を再度ロードするときは、上記の呼び出しで YES を返すようにしてください。または、同期または非同期メソッドを使用して処理できます。

于 2011-08-12T12:40:31.207 に答える