问题
I am loading a PDF from the web using a UIWebView, which works great and lets me interact with the PDF how I want.
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.
My question is, that PDF that UIWebView loads must be cached somewhere, so I really have to do another call to download that same file, just to have UIDocumentInteractionController be able to load it as a local file? Or can I somehow use that same file that UIWebView has already loaded?
回答1:
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];
来源:https://stackoverflow.com/questions/5330161/ios-pdf-loaded-in-uiwebview-then-save-to-ibooks-using-uidocumentinteractioncon