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

iOS 19 leaks are here, and the first new feature is exposed!

Although the official version of iOS 18 has only ...

Basic data that operators must know: Data analysis on "new users"

As an operator , it is essential to deal with dat...

How to configure the company website server rental?

Recently, Jimifeng Network Customer Service has o...

Look! This is our Chinese clothing.

Millennium China Glorious clothes That is (Cao Zh...

Canon 6D Mark II will have two versions, smaller and more professional?

Currently, the most anticipated follow-up models ...

Human research on genetics began with the pea in your bowl

If you ask me which name I am most familiar with ...

Get the latest course on new energy vehicles 2021 Baidu cloud download

Frontier Course: New Energy Vehicles 2021 Hello, ...