How to get the user's touch action in iOS

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.