Sig*_*sen 3 jquery landscape orientation jquery-mobile cordova
嘿家伙我正在使用phonegap和jquery mobile为Android手机构建应用程序.是否有可能将方向锁定在一个页面上?例如,加载页面"地图"并将方向锁定为"横向"模式.
我试图修改manifest.xml,它的工作原理.只需将android:screenOrientation ="landscape"属性添加到您的活动代码中,如下所示:
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
<activity android:label="@string/app_name" android:name=".Phonegap_AppName"
android:configChanges="orientation|keyboardHidden" android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
不是我想的.在xCode for iOS应用程序中是不可能的.我能想出的唯一解决办法就是旋转你的身体或包装纸window.orientation
$(window).bind("orientationchange", function(){
var orientation = window.orientation;
var new_orientation = (orientation) ? 0 : 180 + orientation;
$('body').css({
"-webkit-transform": "rotate(" + new_orientation + "deg)"
});
});
Run Code Online (Sandbox Code Playgroud)
这是一种冒险的方式,但认为这是唯一的方法..
希望这有帮助,请告诉我!
请参阅:http://jsfiddle.net/aalouv/sABRQ/1/
您可以选择绑定到窗口调整大小事件.
$(window).bind("resize", function(){
var orientation = window.orientation;
var new_orientation = (orientation) ? 0 : 180 + orientation;
$('body').css({
"-webkit-transform": "rotate(" + new_orientation + "deg)"
});
});
Run Code Online (Sandbox Code Playgroud)
我刚才写了这个小脚本:它修复了iOS safari中的multiply resize回调错误以及android中的非/ late-/early-trigger(1)orientationchange错误.
(1)有时它在浏览器更改宽度+高度之前和之后有时不会触发?有线!
if (!(/iphone|ipad/gi).test(navigator.appVersion)) {
$(window).unbind("resize").bind("resize", function() {
$(window).trigger("orientationchange");
});
}
Run Code Online (Sandbox Code Playgroud)
如果不是iphone或ipad,则触发窗口上的orientationchange事件.
因此,当您将绑定任何函数时,您执行调整大小会抛出orientationchange.
| 归档时间: |
|
| 查看次数: |
34760 次 |
| 最近记录: |