iPhone Web App 启动画面延迟
我已经构建了一个 iPhone Web 应用程序,并完成了使其看起来像本机应用程序的所有步骤:应用程序图标、防止滚动、防止选择、使用基于触摸的 js 方法等。但是,我遇到了困难与闪屏。
我尝试过使用清单文件缓存的 320x460 PNG 和 JPEG。启动图像确实出现,但仅在应用程序启动并显示白屏几秒钟后出现。因此,在应用程序完成启动之前,启动画面实际上只显示了几分之一秒。
我不明白为什么它没有立即加载启动画面。我知道它被清单缓存,因为它在没有互联网连接的情况下加载。我之前读到,在 DOM 准备好之前,启动画面不会显示,所以我猜这就是问题所在,但我不知道如何解决它。
I've built an iPhone web app and have done all the steps to make it look like a native app: app icon, prevent scrolling, prevent selection, use touch-based js methods, etc. However, I'm having a tough time with the splash screen.
I have tried a 320x460 PNG and JPEG, cached with a manifest file. The splash image does appear, but only after a few seconds after the app launches with a white screen. So, really the splash screen shows up only for a fraction of a second before the app finishes launching.
I can't figure out why it isn't loading the splash immediately. I know it is cached by the manifest because it loads without an internet connection. I read before that the splash doesn't show up until the DOM is ready, so I'm guessing that's the problem, but I don't know how to fix it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否将其与启动链接一起插入?
我还发现,有时当我对 iPhone Web 应用程序进行更改时,我必须完全删除主屏幕上的链接,并在正确更新某些元素之前再次执行添加它的过程 - 即使在更新缓存清单之后。
Are you inserting it with the startup link?
I also found that sometimes when I made changes to my iPhone web apps I had to completely remove the link on the home-screen and go through the process of adding it again before some of the elements updated properly - even after updating the cache-manifest.
如果您使用的是 Sencha Touch,我发现问题与此相关。
为了尝试计算出屏幕尺寸,他们添加了 2 个巨大的 500 毫秒延迟。这会额外增加一秒钟的加载时间。
我已成功将 iPhone 上的时间缩短至 50 毫秒。我不确定代码的功能如何,但它对我有用。
该代码首先检查我们是否在使用 iPhone。这样我只改变了 iPhone 的功能。我无法访问任何其他设备进行测试。
我确实认为即使这样也可以做得更好。例如,在 iPhone 的独立模式下,我们确切地知道屏幕的高度。
暂时就这样吧
希望这有帮助。
If you're using Sencha Touch I found the problem to be related to that.
To try and work out the screen size they have added 2 massive 500ms delays. This adds an extra second to the load time.
I've managed to reduce the time to 50ms on an iPhone. I'm not sure how well the code functions but it works for me.
The code firstly checks that we're on the iPhone. This way I've only changed the functionality for the iPhone. I haven't got access to any other devices to test on.
I do think that even this can be done better. For example in standalone mode on the iPhone we know exactly how high the screen is.
It'll do for now.
Hope this helps.
这将为您的 Web 应用程序添加一个启动屏幕。以下是 iPad 和 iPhone/iPod Touch 所需的尺寸,其中也包括状态栏区域。
iPad 横向 – 1024 x 748
iPad 纵向 – 768 x 1004
iPhone/iPod Touch 纵向 – 320 x 480(标准分辨率)
iPhone/iPod Touch 纵向 – 640 x 960 像素(Retina 显示屏高分辨率)
如果创建与 iPad 兼容的 Web 应用程序建议同时使用横向和纵向尺寸。
编辑:此外,您需要清除缓存并重命名文件(例如,从 image.png 到 new_image.png),以便设备加载新的[正确]图像。第一次启动网络应用程序时,它不会显示启动屏幕,甚至第二次也不会显示启动屏幕,具体取决于您是否有足够的时间将所有必需的文件加载到设备的内存中。
This will add a Splash Screen to your Web App. Below are the sizes you’ll need for both iPad and iPhone/iPod Touch, these include the status bar area as well.
iPad Landscape – 1024 x 748
iPad Portrait – 768 x 1004
iPhone/iPod Touch Portrait – 320 x 480 (standard resolution)
iPhone/iPod Touch Portrait – 640 x 960 pixels (Retina Display high-resolution)
If creating a Web App for iPad compatibility it’s recommended that both Landscape and Portrait sizes are used.
EDIT: Also, you need to clear your cache and rename the file (example, from image.png to new_image.png) so that the device will load the new [correct] image. It will not show the splash screen the first time you launch the web app, and maybe not even the second depending on if you give it enough time to load all of the required files into the device's memory.