css - 如何停止屏幕从 Phonegap 应用程序顶部滚动?

标签 css cordova scroll zepto

我目前正在使用 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/

相关文章:

php - 拥有带有向上滑动博客页面的全屏网站

javascript - 向下滚动页面出现图像 | Sharepoint 在线嵌入

node.js - Ionic 和 Cordova 已安装,但命令无法识别

ios - 添加 Cordova 平台时出错添加 iOS

html - 滚动时部分内容与标题重叠

javascript - css, jasny fileinput - 旋转缩略图

android - Phonegap 错误 : ANDROID_HOME is not set

Swift collectionview 幻灯片上的幻灯片对齐

list - ScrolltoIndex 在平面列表上不起作用 react 原生

jquery - 到达 div 时更改 ul 样式(滚动)