为什么无法在uiwebview中打开.docx文件

时间:2012-08-05 20:54:57

标签: iphone ios ipad uiwebview

我是iphone的新手,我正试图在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]));
}
}

任何帮助??

1 个答案:

答案 0 :(得分:1)

根据http://developer.apple.com/library/ios/#qa/qa1630/_index.html#//apple_ref/doc/uid/DTS40008749,您根本无法打开.docx文件,只能打开.doc文件,这可能是您的问题