How to remove panGesture after touch in swift

此生再无相见时 提交于 2019-12-24 14:43:22

问题


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

    }

Thanks!


回答1:


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.



来源:https://stackoverflow.com/questions/32274838/how-to-remove-pangesture-after-touch-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!