An iOS device is a multi-touch device that can control multiple fingers on the screen. So how do you get the user's gesture action in development? iOS has four finger actions, which are pressed, lifted, moved and canceled. The four methods are as follows:
Press the screen to start touching; override func Touchesbegan (touches:set<nsobject>, withevent event:uievent) { println (" Touchesbegan ") } //Finger lift, end touch; override func touchesended (TOUCHES:SET<NSOBJECT>, withevent event: uievent) { println ("touchesended") } //finger move; override func touchesmoved (touches:set<nsobject Withevent event:uievent) { println ("touchesmoved") } //Touch Cancel override Func Touchescancelled (touches:set<nsobject>!, withevent event:uievent!) { println ("touchescancelled") }
Then test the touch operation by printing it in the console:
(1) Press the finger: Touchesbegan
(2) Press the finger, lift: touchesbegan-->touchesended
(3) Finger slide: touchesbegan-->touchesmoved-->touchesended
During the testing process, no call to the Touchescancelled method was found, and I am not sure when this method is called. Later used to make up for everyone. Different responses can be made later depending on the user's actions.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
How to get the user's touch action in iOS