ios4 中 webview 的 javascript (iscroll4) 滚动解决方案推翻/禁用本机手势识别

发布于 2024-12-21 00:10:46 字数 730 浏览 3 评论 0原文

在我的 iPad 应用程序中,我有一个 UIScrollView(水平滑块 - 类似于图像轮播),其中包含多个 UIWebView - 每个视图都占据整个屏幕。每个 Web 视图的顶部都有一个头栏,并且在必要时可以垂直滚动内容,这些内容应该滚动到栏后面。这是在 html 和 css 中完成的,头栏的位置:固定。

在iOS5中可以正常工作,但在iOS4中却失败了。这是一个已知问题,针对此问题有多种 JavaScript 解决方案,例如来自网站 doctyper 或iScroll4 或触摸滚动(基于 iScroll)。

这些解决方案在垂直滚动方面效果很好。我现在的问题是,只要我在垂直可滚动 div 容器内开始滑动手势(几乎占据整个屏幕 - 除了每侧的几个像素),我就无法再水平滑动(从 UIWebView 到 UIWebView)。 JavaScript 解决方案似乎阻止了 UIScrollView 水平滑动的手势识别。

我什至不确定是否可以在 Objective-C 端或 javascript 或 html 端找到解决方案。任何帮助表示赞赏。即使这只是正确方向的暗示。 谢谢。

In my iPad app I have a UIScrollView (a horizontal slider - similar to an image carousel) which contains several UIWebViews - each of which takes the whole screen. Each webview has a head-bar on top and vertically scrollable content that should scroll behind the bar if necessary. This is done in html and css with position:fixed for the head-bar.

It works fine in iOS5 but fails in iOS4. This is a known issue and there are several javascript solutions for this problem, e.g. from website doctyper or iScroll4 or touch-scroll (which is based on iScroll).

These solutions work nicely in regards to the vertical scrolling. My problem now is that I cannot swipe horizontally (from UIWebView to UIWebView) anymore as long as I start the swipe gesture inside the vertically scrollable div-container (which takes almost the whole screen - except for a few pixels on each side). The javascript solutions seem to prevent the gesture recognition of a horizontal swipe from UIScrollView.

I am not even sure if the solution is to be found on the objective-c side or on the javascript or html side. Any help is appreciated. Even if it is just a hint in the right direction.
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗恋未遂 2024-12-28 00:10:46

我在此处找到了问题的答案。在 iscroll-lite.js 中,您必须取消第 60 行的注释。在第 225 行的正下方,

timestamp = e.timeStamp || Date.now(); 

您必须添加以下行

if (Math.sqrt(deltaY * deltaY) > 3) {
    e.preventDefault();
}

现在我可以使用 iscroll 垂直滚动和 iOS 水平滚动的辅助功能。

I found the answer to my question here. In iscroll-lite.js you have to uncomment line 60. And in line 225 right under

timestamp = e.timeStamp || Date.now(); 

you have to add the line

if (Math.sqrt(deltaY * deltaY) > 3) {
    e.preventDefault();
}

Now I can use the scrolling aid of iscroll vertically and the iOS-scrolling horizontally.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文