![](/img/trans.png)
[英]iOS webapp viewport that fits iphone but automatically scales on iPad
[英]Accelerometer in a iOS Safari/WebApp in iPhone and iPad
我找到了一種通過聽眾找出設備方向的方法(人像,左橫向,右橫向,上下顛倒)
<body onorientationchange="updateOrientation();">
並在標題中
function updateOrientation() {
switch(window.orientation) {
case 0:
// normal
// do some cool things...
break;
case -90:
// right
// do some cool things...
break;
case 90:
// left
// do some cool things...
break;
case 180:
// upside down
// do some cool things...
break;
}
}
但是實際上是否有可能一般地找到加速度計的X / Y / Z值?
在iOS 4.2中,可以使用DeviceMotionEvent類。 這是描述如何使用它的博客文章:
http://www.mobilexweb.com/blog/safari-ios-accelerometer-websockets-html5
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.