【问题标题】:Phonegap iOS iScroll 5 View Moves Up on Virtual KeyboardPhonegap iOS iScroll 5 视图在虚拟键盘上向上移动
【发布时间】:2014-01-27 10:04:15
【问题描述】:
我正在使用 Phonegap、jQuery 和 iScroll 5 为 iOS 构建本机应用程序。 iScroll 完美地工作,除了当我专注于页脚中的输入字段时。虚拟键盘出现并将整个视图向上推。标题不在视图中,我无法滚动到页面顶部。当输入字段失去焦点或模糊时,一切都会恢复正常。我读过 iScroll 没有检测到屏幕大小的变化,但我不知道如何修复它。我试过 window.scrollTo(0, 0) 和 scrollTop() 都没有运气。谢谢!
【问题讨论】:
标签:
jquery
ios
cordova
iscroll
【解决方案1】:
我为此苦苦挣扎了好几个星期。
试试
body{
overflow: hidden;
position: fixed;
top:0;
min-height: 480px; /* Window height for iPhone 5*/
}
在xml中:
<preference name="HideKeyboardFormAccessoryBar" value="true" />
我更改了 CDVViewController.m
来自
CGFloat actualKeyboardHeight = (keyboardFrame.size.height - accessoryHeight);
newFrame.size.height -= actualKeyboardHeight;
到
newFrame.size.height -= 0;
现在这对我有用,只要我在一页上没有多个输入字段,我实际上需要一些滚动。
【解决方案2】:
滚动包装的 scrollTop 值可能会在出现虚拟键盘时发生变化,即使它的 css 溢出属性是 'hidden';
我在 hidekeyboard 事件处理程序中将包装器的 scrollTop 重置为 0;