iOS - PDF在UIWebView中加载,然后使用UIDocumentInteractionController保存到iBooks [英] iOS - PDF Loaded in UIWebView then save to iBooks using UIDocumentInteractionController

查看:213
本文介绍了iOS - PDF在UIWebView中加载,然后使用UIDocumentInteractionController保存到iBooks的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UIWebView从网上加载PDF,效果很好,让我可以按照我想要的方式与PDF进行互动。

I am loading a PDF from the web using a UIWebView, which works great and lets me interact with the PDF how I want.

接下来我想成为能够将该PDF保存到iBooks,所以我使用的是UIDocumentInteractionController。在阅读文档时,您似乎只能将UIDocumentInteractionController与本地文件一起使用,而不是像我一样使用远程文件。

Next I would like to be able to save that PDF to iBooks, so I am using a UIDocumentInteractionController. In reading the docs it seems that you can only use UIDocumentInteractionController with local files rather than a remote file like I have.

我的问题是,该UI即UIWebView load必须缓存在某个地方,所以我真的必须再做一次调用来下载同一个文件,只是为了让UIDocumentInteractionController能够将它作为本地文件加载?或者我可以以某种方式使用UIWebView已经加载的相同文件吗?

推荐答案

您无法直接访问UIWebView缓存的数据。如果您只想下载PDF一次(这是正确的方法),请自己在本地保存文件。然后将其加载到UIWebView中,如下所示:

You can't directly access the data that the UIWebView caches. If you only want to download the PDF once (which is the right way to do it), save the file locally yourself. Then load it in your UIWebView like so:

NSURL* url = [NSURL URLWithString:@"path to local file"];
NSURLRequest* urlRequest = [[NSURLRequest alloc] initWithURL:url];
[myWebView loadRequest:urlRequest];
[urlRequest release];

这篇关于iOS - PDF在UIWebView中加载,然后使用UIDocumentInteractionController保存到iBooks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆