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"; 
};