我真的需要让 UIWebView 打开我项目目录中的特定 PDF 文档.我似乎找不到任何关于此的教程.找到了一个,但是作者没有具体说明一些代码.
I really need to make a UIWebView open up a specific PDF document that is in my project directory. I can't seem to find any tutorials on this. I found one, but the author was not specific about some of the code.
我不得不假设它必须是一段相当简单的代码.
I have to assume it's got to be quite a simple bit of code.
有人可以帮我编写 UIWebView 代码来加载 PDF 吗?
Can someone help me code UIWebView to load a PDF?
谢谢.
使用 pathForResource 和 fileURLWithPath:
Use pathForResource and fileURLWithPath:
NSString *path = [[NSBundle mainBundle] pathForResource:@"FileNameHere"
ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
这篇关于如何让 UIWebView 从它自己的应用程序中显示一个 pdf 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!