如何使UIWebView中显示的pdf中的超链接起作用

发布于 2024-10-09 13:10:43 字数 857 浏览 0 评论 0原文

给定一个使用包含工作嵌入超链接的页面创建的 pdf,将其作为资源存储在我的应用程序中并显示在 UIWebView 中,需要做什么才能使超链接在 UIWebView 中工作。

浏览这里和其他地方关于这个主题的帖子后发现,如果您希望链接在 Safari 中显示,它应该可以正常工作。我无法让他们工作。

在页面中,我创建了文档并创建了一个指向 http://www.excite.com/ 的超链接以进行测试。然后我将该文档导出为 pdf 格式。当 pdf 以预览方式显示时,该链接可以正常工作。然后,我将 pdf 添加到我的应用程序资源文件夹中,并将其加载到 UIWebView 中。该链接不起作用。

UIWebView 是用 IB 创建的,我检查了 Links 属性。

我正在使用以下代码加载 pdf...

NSString *pdfPath =[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:[documents objectAtIndex:documentNumber]];
pdfUrl = [NSURL fileURLWithPath:pdfPath];

[webView loadRequest:[NSURLRequest requestWithURL:pdfUrl]];

我还需要做什么?

现在我只想在 Safari 中打开该链接。最终我需要有链接,允许我链接到资源文件夹中的其他 pdf 并在同一个 UIWebView 中显示它们。为此,我知道我需要实现一个 UIWebViewDelegate。

谢谢,

约翰

Given a pdf created with pages that includes working imbedded hyperlink, stored as a resource with my app and displayed in a UIWebView, what needs to be done to make the hyperlink work in in the UIWebView.

Scouring the posts here and elsewhere on this subject it appears that a link should just work if you want it to display in Safari. I can't get them to work.

In pages I created the document and created a hyperlink to http://www.excite.com/ for testing purposes. I then exported the document as a pdf. The link works fine when the pdf is displayed in Preview. I then added the pdf to my app resources folder and loaded it into the UIWebView. The link does not work.

The UIWebView was created with IB and I have the Links property checked.

I am loading the pdf with the following code...

NSString *pdfPath =[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:[documents objectAtIndex:documentNumber]];
pdfUrl = [NSURL fileURLWithPath:pdfPath];

[webView loadRequest:[NSURLRequest requestWithURL:pdfUrl]];

What more do I need to do?

For now I just would like the link to open in Safari. Eventually I will need to have links that allow me to link to other pdfs in my resource folder and display them in the same UIWebView. To do this I understand I will need to implement a UIWebViewDelegate.

Thanks,

John

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文