2

我是 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]));
}
}

有什么帮助吗??

4

1 回答 1

1

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

于 2012-08-05T20:59:23.187 回答