[英]UIGestureRecognizer not receiving touches during UIScrollView deceleration
I've been trying to create a UITextView
subclass that handles swiping away the keyboard like in the Message.app. 我一直在尝试创建一个UITextView
子类,该子类可以像在Message.app中一样处理键盘滑动。
I have a UIPanGestureRecognizer
added to the keyWindow
of my app, and the gesture delegate is configured for shouldRecognizeSimultaneouslyWithGestureRecognizer
. 我将UIPanGestureRecognizer
添加到应用程序的keyWindow
中,并且将手势委托配置为shouldRecognizeSimultaneouslyWithGestureRecognizer
。 Everything works fine except for when the UIScrollView
is decelerating, during that phase it is possible to pan without the touches being registered. 除了UIScrollView
减速时,其他一切都正常,在此阶段可以平移而无需注册触摸。
You can take a look at a very simple github sample project here . 您可以在此处查看一个非常简单的github示例项目 。
I have tried adding the UIPanGestureRecognizer
directly to the viewController.view and to the scrollView, same issue occurs. 我尝试将UIPanGestureRecognizer
直接添加到viewController.view和scrollView中,发生同样的问题。 I have also tried setting scrollView.panGestureRecognizer requireGestureRecognizerToFail:
with my UITextView
subclass gesture recognizer. 我也尝试过使用UITextView
子类手势识别器设置scrollView.panGestureRecognizer requireGestureRecognizerToFail:
Any ideas as to why this may be happening? 关于为什么会发生这种情况的任何想法?
除了创建新的UIPanGestureRecognizer
,您还可以在UIScrollView
上使用它,然后通过- (void)addTarget:(id)target action:(SEL)action
将自己的平移逻辑添加到该手势识别器中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.