如何使UIWebView中显示的pdf中的超链接起作用
给定一个使用包含工作嵌入超链接的页面创建的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论