Can I prevent the mobile safari from automatically rotating the screen on iPod touch or iphone?

We have a standalone Safari application with a user interface designed for vertical use (perfect pixel). We would like the user interface to remain upright no matter how the user rotates the ipod / iphone. Is this possible with the standalone Safari app?

This question is exactly the same as Can I prevent the mobile safari from automatically rotating the screen on ipod touch or iphone? . However, the question mentioned does not have a definite answer and was prematurely accepted.

+3
source share
1 answer

I do not know how to prevent rotation if it should run in Safari, and not in a native application with a built-in UIWebView interface.

While you cannot prevent rotation, you can compensate for this as follows:

  • Rotation detection using updateorientation event
  • In the event handler, find the current orientation using window.orientation. (e.g. 0, 90, -90, 180).
  • Update the class of your element to reflect the current orientation, and use styles such as -webkit-transform: rotate (-90deg) to rotate your interface in the opposite direction.
  • Use window.scrollTo (0, 1) if necessary; to scroll the address bar on the screen.
+3
source

Source: https://habr.com/ru/post/1740339/


All Articles