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

Apple releases iOS9 GM and iOS9.1 Beta 1

On September 10, as expected, after the press con...

User growth and basic process!

However, today's article wants to do one thin...

WeChat's major update: Video accounts can now post 1-hour long videos

With the cheap price of traffic, video has become...

9 tips to teach you how to upgrade your own media to social media!

If social media is the best way out for self-medi...

Are you still missing an ecosystem to become a “great” Internet company?

Is it reliable for startups to build their own ec...