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

stateof.ai: 2020 Artificial Intelligence Report

Stateof.ai has released its latest "Artifici...

No kidding! Xinjiang really produces seafood!

Xinjiang's seafood harvest is booming What ot...

It’s fun to play with your phone while lying down. I loved it before I became blind.

Science and technology are the languages ​​we use...

11 economic phenomena necessary for planning and promotion

Introduction: Starting from the essence and findi...

How a designer wrote and released an app in 4 months

[[132950]] The story behind GAget, the Google Ana...

If you find an illegal mini program, how do you report it?

Q: How do I report a mini program? Or can someone...