html - iOS 8 : web app status bar position and resizing problems

标签 html ios mobile ios8

设置meta标签时

apple-mobile-web-app-capable


apple-mobile-web-app-status-bar-style

要创建全屏网络应用程序,iOS 状态栏位于屏幕顶部(半透明),底部还有一个额外的空黑条。

这是我的代码:

<!DOCTYPE html><html><head><meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
</head>
<body><h1>Test</h1>
<p>Capture a photo using camera</p>
<input type="file" capture="camera" accept="image/*">
</body></html>

apple-mobile-web-app-status-bar-style 标签还有一个问题。通过相机输入拍摄并接受照片后,屏幕两侧会出现黑条。 我在 iPad3 上使用 iOS8 GM。

我认为这可能是 iOS 8 的错误,但 Apple 似乎并不关心我的错误报告:(

有人知道这个问题的解决方案/解决方法吗?

更新 1: Apple 在 9 月 19 日将我的错误报告标记为重复(已关闭)。

更新 2: 错误已在 iOS 8.3 Beta 1 中修复

最佳答案

从技术上讲,这不是您问题的答案,但我在尝试自己解决此问题时一直在记录我的发现,以下是我目前的发现。我打算将其作为自己的问题发布,但认为它会作为重复项被关闭。

在运行固定网络应用程序的 iOS8 设备上。关于标签:

<meta name="apple-mobile-web-app-status-bar-style" content="black">

来自 the Apple developer reference :

If content is set to default, the status bar appears normal. If set to black, the status bar has a black background. If set to black-translucent, the status bar is black and translucent. If set to default or black, the web content is displayed below the status bar. If set to black-translucent, the web content is displayed on the entire screen, partially obscured by the status bar. The default value is default.

要启用此功能,您需要使用

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

在 iOS6 和 7 中,这或多或少符合预期。

在 iOS8 中,这似乎完全被打破了。例如,在竖屏 iPad Air 上运行的 iOS 8.0.2 具有以下行为:

  • black 产生透明背景。屏幕底部有实心黑条
  • 默认 或不设置值会导致透明背景和屏幕底部的实心白色
  • black-translucent 产生透明背景,但屏幕底部没有恼人的横条

在所有情况下,内容都会出现在栏的“下方”。即栏不会将内容向下推。

在 iPhone6 上,状态栏根本不会横向显示。然而,在肖像中,以下行为:

  • black 按预期工作,内容被下推(哇!!!)
  • default 顶部有一个空白条
  • black-translucent 产生透明背景,内容在下方

我还没有机会在 iPhone6+ 上进行测试

xcode 中的 iOS 模拟器似乎无法可靠地再现真实设备上发生的行为。

我试过用 javascript 动态改变它,但它似乎没有效果。

只是为了让这更有趣/更令人沮丧,您可以通过在 html 元素上设置样式来覆盖状态栏(时钟/wifi 等)。例如

  html {background: black;}
  body {background: #DDD; margin-top: 20px}

其他地方记录的相同问题:

关于html - iOS 8 : web app status bar position and resizing problems,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25884806/

相关文章:

Javascript JSON 数据操作库

javascript - 文本较大时如何将文本移动到同一行的新行

具有多个子类的选择器的 HTML 语法

ios - 应用程序后台刷新ios9 swift

c# - Xamarin 表单按钮在 iOS 上带有文本和矢量图像

javascript - 通过 HTML 为移动应用程序提供高性能 JavaScript 图表 API

html - 如何截断 HTML 字符串以保持固定的列大小

php - 数据库倒计时

ios - 防止 Xamarin.Forms.iOS 中的编辑器自动滚动

javascript - 使用 Javascript window.location 方法通过移动设备重定向用户