在iPad上强制定位 - javascript [英] Force orientation on iPad - javascript

查看:125
本文介绍了在iPad上强制定位 - javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在iPad的浏览器中构建一个应用程序,并想知道是否可以锁定视口的方向?我检查了苹果的文档,我发现的唯一一个方面是只读: https://developer.apple.com/documentation/webkitjs/domwindow/1632568-orientation

I'm building an app in the browser for the iPad and was wondering if it's possible to lock the orientation of the viewport? I've checked apple's documentation and the only thing I've found says orientation is read only: https://developer.apple.com/documentation/webkitjs/domwindow/1632568-orientation

我认为这意味着没有在浏览器中锁定方向的方法。有人有任何想法吗?

I'm thinking this means that there is no way to lock the orientation in the browser. Anyone got any ideas?

推荐答案

没有。我想这对用户来说似乎过于严格,因此您只能检测UI方向。锁定方向的唯一方法是设备侧面的外部开关。

No. I guess this would appear too restrictive to the user, so you can only detect UI orientation. The only way to lock the orientation would be the exterior switch on the side of the device.

参见这个答案代码检测它。您也可以使用 window.orientation 来获取它。

See this answer for code to detect it. You could also just use window.orientation to get it.

对于我的webapps,我只是有一个popover-视图提醒用户在不希望方向时旋转设备。您甚至可以考虑针对不同方向的两个UI设置,以获得更加可定制的体验。

For my webapps, I simply have a popover-view that alerts the user to rotate their device when its orientation is not desirable. You might even consider two UI setups for different orientations for a more customizable experience.

这篇关于在iPad上强制定位 - javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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