view .doc, .docx, .rtf, .ppt file in iphone using Webview

后端 未结 4 867
闹比i
闹比i 2021-02-04 19:39

I want to view .doc, .docx, .rtf, .ppt file in iphone.

But I guess something is going wrong at my side and its not working for the above formats but my code is working f

4条回答
  •  长发绾君心
    2021-02-04 20:12

    Not all of those formats (docx) are supported. This looks like the official word. In the example Apple does not specify a mime type.

    This question suggests that you must use an NSURLRequest instead of loadData.

    Edit:

    As far as I have seen, you cannot directly pass data to loadData for these types.

    The easy work around is to write to a temporary file. You can delete it in webViewDidFinishLoad or, technically, as soon as the the file has been opened.

    The hard work around is to use NSURLCache. You should be able to implement a custom NSURLCache and have WebKit use it via setSharedURLCache. Your cache would basically know how to get your local encrypted files and pretend that they are cached. I have not tried this, but I think it is your best bet. This approach may be blocked just like loadData is.

提交回复
热议问题