iPhone SDK - 添加“添加到主屏幕"UIWebView 中的按钮 [英] iPhone SDK - Add a "Add to Home Screen" button in a UIWebView

查看:15
本文介绍了iPhone SDK - 添加“添加到主屏幕"UIWebView 中的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个原生 iPhone 应用程序,它有一个 UIWebView 组件.我正在尝试查看是否可以复制 Safari 中标签栏选项中的添加到主屏幕"按钮.

I have a native iPhone app, which has a UIWebView component to it. I am trying to see if I can replicate the "Add to Home Screen" button that is present in the tab bar options in Safari.

这可能在原生应用的 UIWebView 中实现吗?

Is this possible inside a UIWebView within a native app?

谢谢!布雷特

推荐答案

[我想你的问题是关于复制与添加到主屏幕相关的操作,而不是复制按钮本身的外观(这是迂腐的就是你实际写的).]

[I presume your question is about replicating the action associated with add to home screen, rather than replicating the appearance of the button itself (which being pedantic is what you actually wrote).]

正如其他人所说,这是不可能的.

As others have said this isn't possible.

您可以做的是从您的应用程序中以编程方式启动 Safari,并为其提供要加载的页面的 URL,即您的页面.

What you could do is programatically launch Safari from within your app and give it the URL of a page to load which is your page.

当您的页面加载时,它会显示某种动画并向用户显示添加到主屏幕按钮的位置,并告诉他们在单击网页中显示的链接后按下它.当用户点击链接时,它会将他们带到您希望保存到桌面的任何页面,并且您希望他们按照您的指示进行操作.

When your page is loaded it has some sort of animation and shows the user where the add to home screen button is and tell them to press it after clicking a link which is displayed in your web page. When the users click on the link it takes them to whatever page it is that you would like saved to the desktop, and you hope they follow your instructions.

如果您注册您的应用以处理专有 url 方案,则用户可以通过单击使用您应用的 url 方案的链接从 Safari 中返回到您的应用.

If you register your app to handle a proprietary url scheme the users can get back to your app from within Safari by clicking on a link using your app's url scheme.

但是,您为 Safari 播种的网页必须是远程页面,您不能在您的应用程序包中为 Safari 提供一个页面,或者您的应用程序已下载,因为 Safari 无法从您的应用程序的沙箱中读取页面.

The web pages that you seed Safari with must however be remote pages, you cannot give Safari a page in your app's bundle or that your app has downloaded as Safari cannot read pages from your app's sandbox.

这篇关于iPhone SDK - 添加“添加到主屏幕"UIWebView 中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆