简体   繁体   English

移动野生动物园与主屏幕webapp

[英]Mobile safari vs home-screen webapp

I am developing a webapp for iOS, and I've noticed some weird things between running on mobile safari and running from the homescreen. 我正在为iOS开发一个webapp,我注意到在运行移动游戏和从主屏幕运行之间有一些奇怪的事情。

Are there any resources that either provide a common interface for going between the modes? 是否有任何资源可以提供在模式之间切换的通用接口?

If not, are there any resources detailing all of the differences and gotchas between the two modes? 如果没有,是否有任何资源详细说明两种模式之间的所有差异和陷阱?

Things I've run into: 我遇到的事情:

Long-polling is kinda weird. 长轮询有点奇怪。 See this example . 这个例子

window.innerWidth & window.innerHeight are inconsistent. window.innerWidthwindow.innerHeight不一致。

  • Mobile Safari- vertical orientation works as expected, horizontal doesn't 移动Safari-垂直方向按预期工作,水平方向不工作
    • Vertical 垂直
      • width- 768 宽度-768
      • height- 946 身高 - 946
    • Horizontal
      • width- 769?? 宽度-769 ??
      • height- 518?? 身高 - 518 ??
  • Web App on Homescreen- These always make sense. 主屏幕上的Web应用程序 - 这些总是有意义的。
    • Vertical 垂直
      • width- 768 宽度-768
      • height- 1004 身高-1004
    • Horizontal
      • width- 1024 宽度 - 1024
      • height- 748 身高 - 748

Additional stuff: 其他东西:

I found this and this to be interesting. 我发现了这个很有意思。

This question also sheds some light on weird behaviors. 这个问题也揭示了奇怪的行为。

I don't think Apple has publicly documented the attributes of the full screen web apps in iOS, so anything you find may be anecdotal, and therefore not reliable enough to depend on in future releases. 我不认为Apple公开记录了iOS中全屏web应用程序的属性,因此您发现的任何内容都可能是轶事,因此在未来的版本中不够可靠。

You may have better luck building an application which has just a UIWebView rendering your web app. 您可以更好地构建一个只有UIWebView呈现您的Web应用程序的应用程序。 The view modes for iOS applications are clearly defined and well documented, and the application can provide other features you may need in the future (such as local notifications, background execution, custom URL handlers). iOS应用程序的视图模式已明确定义并且文档齐全,应用程序可以提供将来可能需要的其他功能(例如本地通知,后台执行,自定义URL处理程序)。

When using 使用时

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

you will get your window.innerWidth's!!! 你会得到你的window.innerWidth的!!!

When using 使用时

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

you will get >> landscape: 1024 x 690 & portrait: 768 x 946 ('safari' mode) 你会得到>>风景:1024 x 690&肖像:768 x 946('safari'模式)

There are four options that Apple supports on Home Screen apps: icon, splash screen, hiding of toolbar and setting status bar mode. Apple支持主屏应用程序有四个选项:图标,启动画面,隐藏工具栏和设置状态栏模式。

See https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html#//apple_ref/doc/uid/TP40002051-CH3-SW3 . 请参阅https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html#//apple_ref/doc/uid/TP40002051-CH3-SW3

If you're building an app for mobile, you may want to take a look at Sencha Touch which takes away the headache of managing the nuances in mobile devices. 如果您正在构建移动应用程序,您可能需要查看Sencha Touch ,它可以消除管理移动设备细微差别的麻烦。

Then you can just build your regular web app beside it. 然后,您可以在它旁边构建常规Web应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM