2

jquery-mobileを使用していますが、横向きの設定が検出されないようです。私が使用しているもの:

Xcodeバージョン4.1ビルド4B110jquerymobileのiphoneシミュレータバージョン4.3(238.2)

mobile.jsでこれを実行しようとしました

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

シミュレーターを回転させると、明らかに横向きである必要があるときに「ポートレート」というアラートが表示され続けます。

私はここで何か間違ったことをしていますか?また、ジャミットコールでメディアクエリを使用してみました。

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

しかし、役に立たない。私はここで何か間違ったことをしていますか?

ところで、主なバグは、iPhoneを回しても、ディスプレイが縦向きの幅のままになることです。

4

1 に答える 1

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";
};
于 2011-08-12T18:51:36.550 に答える