How do I make UIWebView show a pdf file from its own app?(如何让 UIWebView 从它自己的应用程序中显示一个 pdf 文件?)
问题描述
我真的需要让 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 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何让 UIWebView 从它自己的应用程序中显示一个 pdf 文件?


基础教程推荐
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01