How to Get users' touch operations in iOS

Source: Internet
Author: User

How to Get users' touch operations in iOS

An iOS device is a multi-touch device that can be controlled by multiple fingers on the screen. So how can we get users' gesture operations in development? IOS has four finger operations: Press, lift, move, and cancel. The four methods are as follows:

 

// Press the screen and start to touch; override func touchesBegan (touches: Set
 
  
, WithEvent event: UIEvent) {println (touchesBegan)} // lift your finger and end the touch; override func touchesEnded (touches: Set
  
   
, WithEvent event: UIEvent) {println (touchesEnded)} // move your finger; override func touchesMoved (touches: Set
   
    
, WithEvent event: UIEvent) {println (touchesMoved)} // touch Cancel override func touchesCancelled (touches: Set
    
     
!, WithEvent event: UIEvent !) {Println (touchesCancelled )}
    
   
  
 

Then, test the touch operation by printing it on the console:

 

(1) press your finger: touchesBegan

(2) press your finger and lift it up: touchesBegan --> touchesEnded

(3) sliding fingers: touchesBegan --> touchesMoved --> touchesEnded

 

During the test, I did not find the touchesCancelled method called. At present, I do not know when to call this method. It will be used later. In the future, different responses can be made based on different user operations.

 

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: info-contact@alibabacloud.com 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.