2012-08-05 71 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

相关问题