Implementation of one shake

Source: Internet
Author: User

Implementation of one shake

The shake function is similar to the shake function.

Method 1: analyze the accelerated counting data to determine whether the data has been shaken (complicated)
Method 2: the built-in Shake monitoring API (very simple)

This article introduces Method 2:

Steps for judging the shaking:

1) start shaking Detected

-(Void) motionBegan :( UIEventSubtype) motion withEvent :( UIEvent *) event {

// Do some processing after detection

}

2) Shake canceled or interrupted

-(Void) motionCancelled :( UIEventSubtype) motion withEvent :( UIEvent *) event {

}

3) Shake ends

-(Void) motionEnded :( UIEventSubtype) motion withEvent :( UIEvent *) event {

// Do some processing after the end

}

 

All the above three methods inherit the UIResponder. h In UIKit and can be directly used without the import class or the Delegate inheritance.

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.