【问题标题】:iOS Load and view .docx file in UIWebviewiOS 在 UIWebview 中加载和查看 .docx 文件
【发布时间】:2016-08-04 03:01:33
【问题描述】:

如何在 UIWebView 中加载和查看 .docx 文件? WPS 可以做到。 enter image description here

【问题讨论】:

  • 您是在使用 Objective C 还是在使用 cordova。希望这有效stackoverflow.com/questions/11699850/…
  • 我使用 Objective-C
  • 我上面分享的链接好运吗?
  • 不,它不起作用。谢谢你
  • 好的,我也试试,你是从 URL 获取 docx 文件还是你的包里有它?

标签: ios


【解决方案1】:
NSString *path = [[NSBundle mainBundle] pathForResource:@"data.docx" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:path];
NSData *data = [NSData dataWithContentsOfFile:path];
[self.webview loadData:data MIMEType:@"application/vnd.openxmlformats-officedocument.wordprocessingml.document" textEncodingName:@"UTF-8" baseURL:url];

【讨论】:

  • NSString *path = [[NSBundle mainBundle] pathForResource:@"V3.4-1.docx" ofType:nil];路径是零!!!但是文件是真实的
  • 可以了,文件数据少了一些信息,谢谢。
  • @Lidalu 如果您接受我的回答,我将不胜感激。
猜你喜欢
  • 1970-01-01
  • 2013-01-16
  • 1970-01-01
  • 2011-04-19
  • 1970-01-01
  • 2023-01-23
  • 2014-03-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多