我在下面找到了这个方向测试代码,寻找JQTouch参考资料.这在移动Safari上的iOS模拟器中正常工作,但在Phonegap中无法正确处理.我的项目遇到了与杀死此测试页面相同的问题.有没有办法在Phonegap中使用JavaScript来感知方向变化?
window.onorientationchange = function() {
/*window.orientation returns a value that indicates whether iPhone is in portrait mode, landscape mode with the screen turned to the
left, or landscape mode with the screen turned to the right. */
var orientation = window.orientation;
switch (orientation) {
case 0:
/* If in portrait mode, sets the body's class attribute to portrait. Consequently, all style definitions matching the body[class="portrait"] declaration
in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or …Run Code Online (Sandbox Code Playgroud) 在iOS 6中一切正常.键盘打开并将输入移动到视图中.当键盘关闭时,一切都会回到应有的位置.
在iOS 7中,键盘打开正常,输入仍然在视图中.当键盘关闭时,应用程序的整个下半部分都消失了.我已经将问题跟踪到键盘打开时窗口高度的变化,并且在关闭时不会改变.
在键盘打开之前,窗口高度为568,根据$(window).height(),在打开后,它关闭后为828.文档的高度也相应改变.
我试图阻止窗口调整大小:
$(window).resize(function(e) {
e.preventDefault();
e.stopPropagation();
window.resizeTo(320,480);
return false;
});
Run Code Online (Sandbox Code Playgroud)
我还尝试在键盘关闭后设置尺寸,但没有成功.
我正在使用phonegap 2.7并将KeyboardShrinksView设置为true.
我有一个使用Phonegap和JQuery Mobile构建的应用程序.每当软键盘显示 - 在表单输入等 - 整个页面调整大小.图像,按钮和文字.我假设是打破CSS的东西?
其他人有这个问题,或者知道为什么会出现这个问题?我不得不重新启动应用程序以重置布局.
任何想法赞赏!
谢谢!