我目前正在使用 Phonegap 进行开发。它工作正常,除了顶部有一个小(~1 像素)条,触摸它会导致整个应用程序滚动,这是我不想要的。这是我用来防止应用程序其余部分滚动的方法:
<div id="container" ontouchstart="stopIt(event, true);" ontouchmove="stopIt(event, true);" ontouchend="stopIt(event, false);">
stopIt = function(event, touching)
{
event.preventDefailt();
//Other code
}
还有 CSS:
#container {
width:100%;
height:100%;
}
有谁知道是什么原因造成的,或者如何解决?
最佳答案
我想您是在谈论 iPhone 顶部的状态栏?是的,它将始终滚动到顶部,并且没有办法从浏览器中捕获此事件并停止它。
您需要从 native 端将 Web View 的 scrollToTop 属性设置为 false。这应该有效。
[theWebView setScrollsToTop:NO];
关于css - 如何停止屏幕从 Phonegap 应用程序顶部滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8974462/