Can I prevent mobile safari from auto-rotating the screen on ipod touch or iphone?

血红的双手。 提交于 2019-12-05 21:43:23

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. Detect the rotation using the updateorientation event
  2. In your event handler, find the current orientation using window.orientation. (e.g. 0, 90, -90, 180)
  3. Update the class of your element to reflect the current orientation, and use styles like -webkit-transform:rotate(-90deg) to rotate your UI in the opposite direction.
  4. If necessary, use window.scrollTo(0, 1); to scroll the address bar off the screen.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!