简体   繁体   English

如何启用/禁用触摸已移动,触摸已终止和滑动手势

[英]How to enable/disable touchesMoved, touchesEnded and Swipe Gestures

I am working on a game where I need touchesMoved and touchesEnded but after the stage is completed, I want to DISABLE touchesMoved and touchesEnded and enable only SWIPE GESTURES . 我正在开发需要touchesMovedtouchesEnded的游戏,但是在阶段完成之后,我想禁用touchesMovedtouchesEnded启用SWIPE GESTURES touchesEnded

So how can I achieve this? 那么我该如何实现呢?

When the game is being played : I want swipe gestures to be disabled and touchesBegan , touchesMoved , touchesEnded should be enabled. 在玩游戏时 :我希望禁用滑动手势, touchesEnded应该启用touchesBegantouchesMovedtouchesEnded

When the game is completed : I want touchesBegan , touchesMoved , touchesEnded to be disabled And swipe gestures to be enabled. 游戏结束时 :我希望touchesBegantouchesMovedtouchesEnded被禁用,并且要启用滑动手势。

Please help me out. 请帮帮我。 Thanks. 谢谢。

When you want to disable touch return false in below method. 如果要禁用触摸,请按以下方法返回false。

 func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
    return false
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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