2

我正在使用jquery-mobile,它似乎沒有檢測到橫向設置。我現在用:jquery移動定位檢測

iPhone模擬器版本4.3(238.2)在Xcode 4.1版編譯4B110 jQuery Mobile的

我試圖做這在我mobile.js

$(window).bind('orientationchange resize', function(event){ 
    alert(event.orientation) 
}) 

並打開模擬器周圍只是不斷給我一個警告,說「肖像」,當它顯然應該是風景。

我在這裏做錯了什麼?我也嘗試在我們的jammit通話中使用媒體查詢:

<%= include_stylesheet :landscape, :media => "all and (orientation: landscape)" %> 

但無濟於事。 AM我在這裏做錯了什麼?

主要的錯誤btw是,即使在轉動iphone時,顯示仍然保持在我們的肖像寬度。

+0

HTTP: //jquerymobile.com/dem os/1.0b2 /#/ demos/1.0b2/docs/api/mediahelpers.html注意:此功能在beta版中已棄用,並且在此之後將被刪除。我們建議使用CSS3 Media Queries。 –

+0

在我的問題的最後部分我DID嘗試css3媒體查詢(這也不適合我...) – corroded

回答

0

我發現這個在JQM B2 js文件:

JS:

alert('Orientation: ' + jQuery.event.special.orientationchange.orientation()); 

下面是函數本身:

// Get the current page orientation. This method is exposed publicly, should it 
// be needed, as jQuery.event.special.orientationchange.orientation() 
$.event.special.orientationchange.orientation = get_orientation = function() { 
    var elem = document.documentElement; 
    return elem && elem.clientWidth/elem.clientHeight < 1.1 ? "portrait" : "landscape"; 
};