Shake on iPhone

Shake on iPhone

Source code introduction: It is very simple to implement the shake function on iPhone. Please refer to the following code or download the demo to try it out.

Source code effect:

[[142753]]

Source code snippet:

  1. #pragma mark - shake
  2.  
  3. /**
  4. * Shake to start
  5. */  
  6. - ( void )motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
  7.  
  8. if (motion == UIEventSubtypeMotionShake) {
  9.  
  10. NSLog(@ "Started shaking" );
  11. }
  12. }
  13.  
  14. /**
  15. * Shake ends
  16. */  
  17. - ( void )motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
  18.  
  19. NSLog(@ "Shake ended" );
  20. }
  21.  
  22. /**
  23. * Shake to cancel
  24. */  
  25. - ( void )motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event {
  26.  
  27. NSLog(@ "Shake to cancel" );
  28. }

Download address: http://download..com/data/2076086

<<:  Different ways to deal with girls acting like a spoiled child

>>:  Learning Numerical Algorithms with Playground

Recommend

Childhood memories are not gone, we just can’t read them|Tech Weekly

Compiled by Zhou Shuyi and Pingsheng Why do anima...

Mango TV officially starts its VR journey with Super Girl

Nowadays, it is no longer a new thing for an Inte...

How to conduct poster fission activity? 4 essential tips!

In the entire public account operation circle, ev...

The Douyin system operation guide summarized after a loss of 200,000!

Long article warning: This article is the product...

6 hidden tricks of WeChat, how many have you used? Worth collecting

Xiaoyu shares 6 hidden tricks of WeChat with you....

Can smart technology make cars better?

A means of transportation, a symbol of identity, ...

Why do you have such a hard time finding seed users?

After the product is launched, someone is needed ...

"Air taxis" are here! Can we take a flying taxi when we go out in the future?

In Shanghai, I get off work at 6pm and go to Yang...

Can sunbathing prevent cancer? The health code in the sun!

Have you ever noticed that you feel particularly ...