如何在快速触摸后删除 panGesture [英] How to remove panGesture after touch in swift

查看:30
本文介绍了如何在快速触摸后删除 panGesture的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以识别 UIPanGesture 和单击的视图.点击视图后如何禁用平移手势?我尝试了多种方法,但似乎无法弄清楚.这是我尝试的最后一种方法:

I have a view that recognizes both a UIPanGesture and a single tap. How do I disable the pan gesture once the view has been tapped? I have tried multiple ways but cannot seem to figure it out. Here is the last method I tried:

 func gestureRecognizer(singleTapRecognizer: UIGestureRecognizer?, shouldRequireFailureOfGestureRecognizer panGesture: UIPanGestureRecognizer?) -> Bool? {
    print("in gesture recognizer")
    if wasTapped == true {
        return true
    }
    else {
        return false

    }

谢谢!

推荐答案

我认为您正在寻找类似

I think you're looking for something along the lines of

panGesture.requireGestureRecognizerToFail(singleTapRecognizer)

最好在您创建两个手势识别器后立即调用.

Which would, preferably, be called just after you have created both of the gesture recognizers.

这篇关于如何在快速触摸后删除 panGesture的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆