Has anyone found that UIWebView fails for some URLS?

前端 未结 1 468
说谎
说谎 2020-12-29 07:48

I have been working on an iPhone App for a couple of weeks now and one of the earlier features I added was a UIWebView that loaded context sensitive Wikipedia page

1条回答
  •  孤城傲影
    2020-12-29 08:11

    Looks like there's an answer here:

    How do I fix NSURLErrorDomain error -999 in iPhone 3.0 OS

    which in turn refers to:

    http://www.iphonedevsdk.com/forum/iphone-sdk-development/6280-uiwebview-didfailloadwitherror-how-get-errors-code-list.html

    Looks like you need a hack like this in the webView:didFailLoadWithError: delegate:

    if ([error code] != NSURLErrorCancelled) {
        //show error alert, etc.
    }
    

    In essence what's happening is the delegate is getting a "cancelled" (-999) failure, that might be originated in javascript or perhaps even in a UIWebView bug.

    With your code the webview doesn't show anything at all because you're using the very same UIWebView to display the error. If you had just NSLog'd the error you would have seen a failure, but then the page would have loaded just fine, giving you a hint that the failure is bogus.

    0 讨论(0)
提交回复
热议问题