简体   繁体   中英

Stop touch event during touch move

In my game, when time is up, I want to display another view and stop the interaction on the others currently used before the time stopped. But when the other view is coming, if I let my finger on the screen, I can stil drag into the view behind the new view and continue the game.... That's not the purpose.

I want to lose the focus of the finger, or cancel the finger... I tried to set userInteraction to NO.. but not working.

Can somebody knows how to solve this issue?

The quickFix is to setup a shared variable and test it in the touchBegan and TouchMoved event.. but that's not proper :)

Thank a lot!

Your -touchesMoved:withEvent: method can check whether the timer is still running before it does anything. If the timer expires, it stops changing anything.

1.Ignore the events while animation.

2.Instead of setting userInteraction to NO ignore the events.

Use these methods to ignore events

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[[UIApplication sharedApplication] endIgnoringInteractionEvents];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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