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

Surface mini was killed by Microsoft at the last minute

Microsoft held a new product launch conference in ...

The most complete! New product launch event process planning plan!

The most important thing about an event is to hav...

Feng Qingyang's "Stock Market Practice" Stock Trading Training Lecture No. 2

Training course content: Maybe you spent a lot of...

B150 motherboard is coming, will it be the next most popular motherboard?

In August this year, Intel launched the sixth-gen...

Price war is the "last resort" How long can Baofeng's 999 yuan color TV be sold?

The horn of war has sounded again in the Internet...

Things about bad code

[[148851]] 1. Summary This is the second article ...

To learn how to master Zhihu marketing operations and promotion, read this article!

1. Why do you want to operate Zhihu ? Let’s first...

The secret to Tik Tok user growth!

Bright Dairy, a large traditional enterprise, ord...