在 iPhone 上隐藏 Safari 用户界面组件

发布于 2024-07-08 18:05:41 字数 462 浏览 10 评论 0 原文

尝试隐藏标记为主屏幕图标的 Web 应用程序的 Safari UI 组件。 此元标记

<meta name="apple-mobile-web-app-capable" content="yes" />

我正在使用iPhone 开发中心,但从主屏幕图标启动时地址栏和工具栏仍然存在。 我需要做哪些不同的事情? 有人有例子吗?

In an attempt to hide the Safari UI components for an web-app bookmarked as a Homescreen Icon. I am using this meta tag

<meta name="apple-mobile-web-app-capable" content="yes" />

as specified on iPhone Dev Center but the address bar and toolbar are still there when launched from the home screen icon. What do I need to do different? Does anyone have an example?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

呢古 2024-07-15 18:05:41
window.top.scrollTo(0, 1);

适用于 iPhone,但不适用于 iPad。 我已经成功隐藏了 iPad 上的浏览​​器组件(大概是无处不在)

<meta name="apple-mobile-web-app-capable" content="yes" />

通过使用主屏幕链接并启动, 。 我还

<meta name="viewport" 
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

没有尝试查看如果我忽略视口属性,浏览器组件是否仍然隐藏。

window.top.scrollTo(0, 1);

Works on iPhone, but not in iPad. I have been successful hiding the browser components on iPad (so presumably everywhere) by using

<meta name="apple-mobile-web-app-capable" content="yes" />

and launching from a home-screen link. I am also using

<meta name="viewport" 
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

I have not tried seeing if the browser components are still hidden if I leave out the viewport properties.

末骤雨初歇 2024-07-15 18:05:41

它是从主屏幕启动的吗? 链接页面上的文档没有提及,但我发现了这个@ 配置 Web 应用程序

例如,您可以为 Web 应用程序指定一个图标,用于在添加到主屏幕时代表它,如“为 Web Clip 指定网页图标”中所述。 当您的 Web 应用程序从主屏幕启动时,您还可以最小化 iPhone 用户界面上的 Safari,如“更改状态栏外观”和“隐藏 Safari 用户界面组件”中所述。 这些都是可选设置,当添加到您的网络内容时,其他平台会忽略这些设置

Is it being launched from the home screen? The documentation on the linked page does not mention but I found this @ Configuring Web Applications:

For example, you can specify an icon for your web application used to represent it when added to the Home screen, as described in “Specifying a Webpage Icon for Web Clip.” You can also minimize the Safari on iPhone user interface, as described in “Changing the Status Bar Appearance” and “Hiding Safari User Interface Components,” when your web application is launched from the Home screen. These are all optional settings that when added to your web content are ignored by other platforms

贱人配狗天长地久 2024-07-15 18:05:41

您是否尝试过添加...

<meta name="apple-touch-fullscreen" content="yes" />

Have you tried adding...

<meta name="apple-touch-fullscreen" content="yes" />
旧时模样 2024-07-15 18:05:41

据我所知,iOS 仅在您实际添加应用程序时才会关注这些标志。 如果支持 apple-mobile-web-app-capable 的东西一开始不起作用,请尝试从主屏幕删除您的应用程序,然后重新添加它。

我进行了一些实验并发现:

  • 标题中元标记的位置似乎并不重要(我认为可能!)
  • 在添加应用程序并让它正确删除地址栏之后,如果您然后从网页中删除元标记,iOS 会继续删除工具栏。
  • 即使重新启动设备后,它仍然“记住”是否删除工具栏。 我发现重置此行为的唯一方法是删除并重新添加该应用程序。

希望有帮助!

From what I can tell, iOS only pays attention to the flags when you actually add the app. If the apple-mobile-web-app-capable thingy doesn't work at first, try deleting your app from the home screen then re-adding it.

I've run some experiments and found:

  • the location of the meta tag within the headers doesn't seem to matter (I thought it might!)
  • after adding the app and having it remove the address bar correctly, if you then remove the meta tags from the web page, iOS continues to remove the toolbar.
  • even after rebooting the device it still 'remembers' whether to remove the toolbar. The only way I've found of resetting this behaviour is to remove and re-add the app.

Hope that helps!

眼藏柔 2024-07-15 18:05:41

我知道这已经很老了,但我在寻找解决方案时遇到了这个。 我还可以通过添加:

window.top.scrollTo(0, 1);

到主体的 onload 方法来解决此问题。 希望它能帮助其他遇到这个问题的人。

I know this is pretty old, but I came across this while searching for a solution. I was able to fix this by also adding:

window.top.scrollTo(0, 1);

to the body's onload method. Hope it helps anyone else coming across this.

于我来说 2024-07-15 18:05:41

iOS 浏览器考虑了一个名为“minimal-ui”的新指令(至少在我测试的 iPhone 上)。 工具栏一直隐藏,直到用户单击顶部的状态栏。 对于一页应用程序来说非常好!

这是我使用的代码片段:

There is a new directive, called "minimal-ui" that iOS browser takes into account (at least on the iPhone where I tested). Toolbars are hidden until the user clicks on the status bar on top. Very nice for one page apps!

Here is the snippet I use:

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">

眼眸 2024-07-15 18:05:41

尝试这个

<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width; user-scalable=0;">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="icon.png">

Try this

<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width; user-scalable=0;">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="icon.png">
旧话新听 2024-07-15 18:05:41

从 iOS 7.1 开始,您可以使用 minimal-ui

<meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">

Since iOS 7.1, you can use minimal-ui

<meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">
萌无敌 2024-07-15 18:05:41

这确实应该像预期的那样,我过去使用过它,没有任何困难。

That should indeed behave as expected, I have used it in the past without any difficulties.

那支青花 2024-07-15 18:05:41
<meta name="apple-mobile-web-app-capable" content="yes" />

如果满足以下条件,这将起作用:

  1. 将应用程序添加到主屏幕时,标签存在。
  2. 该应用程序从主屏幕启动。
<meta name="apple-mobile-web-app-capable" content="yes" />

This will work if:

  1. The tag exists when the app is added to the home screen.
  2. The app is launched from the home screen.
轻拂→两袖风尘 2024-07-15 18:05:41
<meta name="apple-mobile-web-app-capable" content="yes" />

适用于 iOS6 + 移动 Safari 浏览器,但仅当您在网站上包含元标记后将页面添加到主屏幕时。

<meta name="apple-mobile-web-app-capable" content="yes" />

works on iOS6 + Mobile Safari Browser but ONLY if you added the page to your homescreen AFTER you included the meta tag on your site.

燕归巢 2024-07-15 18:05:41

以上所有元标记和 window.scrollTo 对我来说在 ipad 上不起作用,
我在 Safari 上的书签旁边发现了一个按钮,您可以在其中找到一个名为“添加到主屏幕”的选项,它会创建一个新的磁贴图标,您可以像本机应用程序一样启动您的网络应用程序,并且那里没有地址栏。

all above meta tags and window.scrollTo, did not work on ipad for me,
i found a button on safari next to bookmarks where you get an option called 'Add to Home Screen' it creates a new tile icon, and you can launch your web app like a native app, and no address bar there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文