2010-08-11 61 views
0

我發現找出設備的定向的方式(肖像,風景左,景觀權,顛倒)通過監聽加速計在iOS的Safari瀏覽器/ Web應用程序在iPhone和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值嗎?

回答

相關問題