Detecting and Configuring UIWebView Error "Cannot Read Document"

I am testing a UIWebview with several types of documents --.xlsx, .jpg, etc. - and he opens most of them just fine. From time to time, I open a local file, and this message appears directly in the web view:

Unable to Read Document
An error occurred while reading the document

I'm not interested in why, this error occurs, for example, when I feed a UIWebView garbage file (intentionally). The problem is that I cannot figure out how to determine when this happens. It does not fire webView: didFailLoadWithError , it does not raise NSException (via @try and @catch >), and when I check the document in webViewDidFinishLoad , webView.request.HTTPBody is null.

Does anyone know how to determine when a UIWebView cannot display content?

+5
source share
2 answers
just call uiwebview delegate method 

- (void)webViewDidStartLoad:(UIWebView *)webView
{

}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    NSString *html = [webView stringByEvaluatingJavaScriptFromString:
                      @"document.body.innerHTML"];
    if ([html rangeOfString:@"Unable to Read Document."].location == NSNotFound) {

       NSLog(@"NO Error");

    }
    else
    {
//        NSLog(@"File contains Error");
    }

}
+3
source

, . ,

Cannot find data converter callback for uti public.data
Failed to generate preview

, . , , , , Word 97 Pages/Pages.zip, , . . , ... , , , , -. , Xcode , .

0

All Articles