PDF 在 UIWebView 中无法正确显示
我有一个 UIWebView,我想在其中显示 PDF 文件。 PDF 文件位于远程网络服务器上,因此像任何其他 URL 一样加载。
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.findsmiley.fvst.dk/KontrolRapport.aspx?id=20328832&akt=1"]]];
但 PDF 无法正确显示。我无法滚动或缩放文档。 在控制台中,我收到以下错误代码(当然,CafeHelmuth 是我的应用程序的名称)
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Terminating in response to SpringBoard's termination.
Program ended with exit code: 0
在下图中,您会看到它不会滚动网页,而是滚动视图,当然, ,是错误的。
谁能帮助我让我的网络视图正确显示 PDF 文档?
在 loadRequest
webView.scalesPageToFit = YES; > 使它看起来有点奇怪,虽然它确实添加了缩放和滚动,但它似乎不是正确的方法。下面是一些这样的图像。
当我放大时,背景变成蓝色,并且.. 嗯,看起来很奇怪。
I have a UIWebView in which I want to display a PDF file. The PDF file is located on a remote webserver and is therefore loaded like any other URL.
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.findsmiley.fvst.dk/KontrolRapport.aspx?id=20328832&akt=1"]]];
The PDF is not displayed correctly, though. I am not able to scroll or zoom the document.
In the console I get the following error codes (CafeHelmuth being the name of my application, of course)
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Wed Mar 23 15:56:31 simonbs-macbook CafeHelmuth[1997] <Error>:
Terminating in response to SpringBoard's termination.
Program ended with exit code: 0
On the image below you see that it does not scroll the web page but the view, which, of course, is wrong.
Can anyone please help me make my web view display the PDF document correctly?
Adding webView.scalesPageToFit = YES;
before loadRequest
makes it look a bit strange, though it does add zoom and scroll but it does not seem to be the right approach. Beneath are some images of this.
When I zoom in the background becomes blue and.. Well, it looks strange.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加一行
webView.scalesPageToFit = YES;
在 loadRequest 行之前
Add a line
webView.scalesPageToFit = YES;
before the loadRequest line
我没有找到任何解决方案来自定义网络视图的行为。但我已经为您的 pdf 找到了解决方案:将 pdf 格式更改为 10.7 厘米 x 15.7 厘米。看一下这个示例:
I didn't find any solution to customize the behaviour of the webview. But I have found a solution for your pdf: Change the pdf's format to 10.7 cm x 15.7 cm. Have a look at this example: