UIWebview で xlsx ファイルのローカル コピーを正常に開くことができます
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]];
しかし、一部のファイルではコンソールログに例外が発生しています。これらの例外がどこから来ているのか、それをトラップする方法がわかりません
<Warning>: exception: Could not find the end of central directory record
<Warning>: EXCEPTION SFUZipEndOfCentralDirectoryError: Could not find the end of central directory record
このファイルは読み込みを開始するだけです
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType <br>
- (void)webViewDidStartLoad:(UIWebView *)webView
が呼び出され、以下のデリゲートはどちらも呼び出されません
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
- (void)webViewDidFinishLoad:(UIWebView *)aWebView <br>
ファイルをロードするいくつかの webview で 2 番目のファイルをロードしようとすると、以前の xlsx に対してdidFailLoadWithErrorが呼び出され、以下のコンソール ログが表示されます。
-----====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
2 番目のファイルのログ
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 :
これは UIWebview のキャッシュによるものですか? UIWebview 例外をトラップするにはどうすればよいですか?