2012-08-05 74 views
2

我在iphone新打開.docx文件,我試圖在UIWebView的爲什麼不能在一個UIWebView

打開.docx文件我用這個代碼:

NSString *urlAddress = [[NSBundle mainBundle] pathForResource:docName 
                 ofType:@"docx"]; 

NSLog(@"the document url address: %@", urlAddress); 

NSURL *url = [NSURL fileURLWithPath:urlAddress]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 

[_webView loadRequest:requestObj]; 

也驗證碼:

NSData *myData = [NSData dataWithContentsOfFile:docName]; 
[_webView loadData:myData MIMEType:@"application/vnd.ms-word" 
    textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@""]]; 

,我敢肯定的是,在資源文件夾中的文件, 但運行時,它給了我一個例外,在main.m文件說,

int main(int argc, char *argv[]) 
{ 
@autoreleasepool { 
    // here it tells me that (Thread 1: signal SIGKILL) 
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([MFAppDelegate class])); 
} 
} 

任何幫助?

+0

你能不能給,你給予了充分的例外呢? – 2012-08-05 20:57:13

+0

你確定它讀取'.docx'嗎?我沒有看到[這裏](http://developer.apple.com/library/ios/#qa/qa1630/_index.html),只有'.doc'。 – cambraca 2012-08-05 20:59:02

+0

當我做第二個代碼它告訴我.. EXCEPTION SFUZipEndOfCentralDirectoryError:找不到中央目錄記錄的末尾 – user1553381 2012-08-05 20:59:38

回答

1

根據http://developer.apple.com/library/ios/#qa/qa1630/_index.html#//apple_ref/doc/uid/DTS40008749你根本無法打開的.docx文件,但只有.doc文件,這是你的問題可能

+0

嗯看看[這個問題](http://stackoverflow.com/questions/11699850/code-to- open-docx-in-iphone-webview) – cambraca 2012-08-05 21:02:08

+0

但我之前試過打開.docx,它只是簡單地打開,但現在我不知道什麼是錯的。它告訴我:EXCEPTION SFUZipEndOfCentralDirectoryError:找不到中央目錄記錄的結尾 – user1553381 2012-08-05 21:06:00

相關問題