我可以阻止Safari在iPod touch或iPhone上自动旋转屏幕吗? [英] Can I prevent mobile safari from auto-rotating the screen on ipod touch or iphone?

查看:136
本文介绍了我可以阻止Safari在iPod touch或iPhone上自动旋转屏幕吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个离线Safari应用程序,其UI专为垂直使用而设计(像素完美).无论用户如何旋转ipod/iphone,我们都希望UI保持垂直.离线Safari应用程序可以吗?

We have an offline Safari application with UI designed for vertical use (pixel perfect). We would like the UI to stay vertical no matter what how the user rotates the ipod / iphone. Is it possible with offline Safari application?

此问题与

This question is exactly the same as Can I prevent mobile safari from auto-rotating the screen on ipod touch or iphone? . Yet - the referenced question has no definite answer and has been prematurely accepted.

推荐答案

如果它需要在Safari中运行,而不是在具有嵌入式UIWebView的本机应用程序中运行,我不知道有什么方法可以阻止旋转.

I'm not aware of any way to prevent the rotation if it needs to run in Safari rather than a native app with an embedded UIWebView.

虽然您不能阻止旋转,但是可以像这样补偿它:

While you can't prevent the rotation, you can compensate for it like this:

  1. 使用updateorientation事件检测旋转
  2. 在事件处理程序中,使用window.orientation查找当前方向. (例如0、90,-90、180)
  3. 更新元素的类以反映当前方向,并使用-webkit-transform:rotate(-90deg)之类的样式沿相反方向旋转UI.
  4. 如有必要,请使用window.scrollTo(0,1);.将地址栏滚动出屏幕.

这篇关于我可以阻止Safari在iPod touch或iPhone上自动旋转屏幕吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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