在UIWebView中滑动手势识别 [英] Swipe Gesture Recognition Inside UIWebView
问题描述
我已经阅读了很多关于此的问题,但它们似乎都没有实现我想要的......所以我可以说我有一个任意的 UIWebView
一个 UIViewController
。 UIViewController
有一个 SwipeGestureRecognizer
,工作正常。它甚至可以在 UIWebView
中工作 - 只要没有滚动条。 (在我加载页面之前,或者即使我加载的页面适合我的 UIWebView
的大小)。但是,如果我加载一个需要向左或向右水平滚动的网页,那么在我的视图的 UIWebView
部分内,我无法识别任何滑动手势。每次单击/拖动/滑动都会触发滚动操作。有没有办法区分滑动和只是用手指滚动(不是提起它而是拖动滚动)。
I have read a bunch of questions on this but none of them seem to achieve what I am looking for... So lets say I have an arbitrary UIWebView
inside of a UIViewController
. The UIViewController
has a SwipeGestureRecognizer
that works fine. It even works within the UIWebView
-- whenever there is no scrollbar. (Before I load a page or even if I load a page that can fit appropriately within the size of my UIWebView
). However, if I load a webpage that requires horizontal scrolling left or right, then inside the UIWebView
part of my view, I cannot get any swipe gestures to be recognized. Every click/drag/swipe just triggers the scroll action. Is there a way to differentiate between a "swipe" and just scrolling with your finger (not lifting it but rather dragging to scroll).
推荐答案
你必须继承UIWebView并覆盖手势识别器调用。
You will have to subclass UIWebView and override the gesture recogniser calls.
编辑 - 看看这篇文章处理UIWebview内的触摸和此链接 http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way /
EDIT - Look at this post Handling touches inside UIWebview and this link http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way/
这篇关于在UIWebView中滑动手势识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!