简体   繁体   English

UIGestureRecognizer在UIScrollView减速期间未收到触摸

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM