HTML5 格式的 iPhone/iPad 上带有后退按钮的 PDF?
我正在尝试为 iOS(而不是路由器)编写一个可打开 PDF 的 HTML5 应用程序。现在我只使用 。这将退出应用程序并在 Safari 中打开 PDF。
如何使用后退按钮将用户带回到我的应用程序,或者在没有 Safari chrome 的情况下查看 PDF?
我正在使用 Sencha Touch 并将与 PhoneGap 一起部署。
I'm trying to write an HTML5 application for iOS (not the routers) that opens PDFs. Right now I'm just using <a href="some.pdf" type="application/pdf">
. This exits the application and opens the PDF in Safari.
How do I get the back button to take the user back to my application, or view the PDF without Safari chrome?
I'm using Sencha Touch and would deploy with PhoneGap.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道有什么简单的方法可以做到这一点,因为您的应用程序也托管在单个 UIWebView 中,因此在其中显示 PDF 将导致无法显示后退按钮或用户无法导航回您的应用程序。
唯一的是,我可以设想这样做是编写一个 PhoneGap 插件,该插件将创建另一个 UIWebView,将其设置为 PDF 的内容,并将其添加到主 UIViewController。然后,您可以将视图设置为距离顶部 x 像素,这将允许您以工具栏方式显示后退按钮。当他们点击返回时,插件会卸载 PDF,破坏视图,而您的应用程序仍在运行。 (您也可以在顶部创建一个带有本机后退按钮的视图,单击该按钮后会隐藏 PDF 的 UIWebView)。
I don't know of an easy way to do this as your application is hosted in a singular UIWebView as well so displaying a PDF in it would result in the inability to display a back button or for the user to navigate back to your application.
The only was that I could envision to do this would be to write a PhoneGap plugin that would create another UIWebView set it to the PDF's content, and add it to the master UIViewController. You would then set the view to be x pixels from the top which would allow you to display a back button in a toolbar fashion. When they click back, the plugin unloads the PDF, destroys the view, and your application is still going. (You could also just create a View on top with a native back button that just hides the PDF's UIWebView when clicked).
您应该创建一个指向 PDF 的
NSURLRequest
并将其提供给您的UIWebView
:我不知道您从哪里获取 PDF,但如果您需要拦截点击在链接上
您还可以通过定义
UIWebView
的委托-webView:shouldStartLoadWithRequest:navigationType:
来实现这一点。You should create an
NSURLRequest
pointing to the PDF and feed it to yourUIWebView
:I don't know where you get your PDF from, but if you need to intercept the click on the link
you can also do that by defining your
UIWebView
's delegate-webView:shouldStartLoadWithRequest:navigationType:
.