Error opening some xlsx file in UIWebview

I can successfully open a local copy of xlsx file in UIWebview

NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@",[detailItem valueForKey:@"path"]]];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
[self.documentWebview loadRequest:[NSURLRequest requestWithURL:fileURL]];

but for some files I get an exception in the console logs. I don’t know where these exceptions come from, and how to catch them,

<Warning>: exception: Could not find the end of central directory record
<Warning>: EXCEPTION SFUZipEndOfCentralDirectoryError: Could not find the end of central directory record

This file only downloads

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType <br>
- (void)webViewDidStartLoad:(UIWebView *)webView

are called & amp; none of the following delegates are called

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
- (void)webViewDidFinishLoad:(UIWebView *)aWebView <br>

When I try to upload the second file to some kind of webview that loads the file, and I get didFailLoadWithError , which is called for the previous xlsx below - console logs

-----====UIWebview shouldStartLoadWithRequest: /var/mobile/Applications/08653237-F656-42F7-B405-1F89C208A866/Documents/12 So1 what is new in Excel 2007.xlsx =======-------
webViewDidStartLoad 
exception: Could not find the end of central directory record 
EXCEPTION SFUZipEndOfCentralDirectoryError: Could not find the end of central directory record

Logs for the second file

webView didFailLoadWithError: Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x5655c30 {NSErrorFailingURLKey=file:///var/mobile/Applications/08653237-F656-42F7-B405-1F89C208A866/Documents/12%20So1%20what%20is%20new%20in%20Excel%202007.xlsx, NSErrorFailingURLStringKey=file:///var/mobile/Applications/08653237-F656-42F7-B405-1F89C208A866/Documents/12%20So1%20what%20is%20new%20in%20Excel%202007.xlsx}
webViewDidStartLoad

Detail View finished /var/mobile/Applications/08653237-F656-42F7-B405-1F89C208A866/Documents/a.txt :


Is this related to UIWebview caching? How can I catch UIWebview exceptions?

+3
source share
1 answer

, , . , , URL- , , html, IIS. . , . !

0

All Articles