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

APP message push strategy and content copywriting!

I am very happy that you clicked into my article ...

How to make steady progress when launching an APP?

That’s the title , but if you ask me how I got 1 ...

What are the differences between chargers of different sizes?

"Chargers come in different sizes. Are there...

What factors do you consider most when buying a USB flash drive?

USB flash drives are definitely the most convenie...

Tractica: Global deep learning software market will reach $67.2 billion in 2025

Deep learning is a buzzword that has received muc...

Analysis of Mobike and ofo bike competition

1. Introduction Test models: Xiaomi MAX, iPhone 6...

What is the difference between the advertising effects of OCPM and OCPC?

This week, I have sorted out several difficult qu...

National Mooncake Awards! Which of these 10 mooncakes do you like best?

Mid-Autumn Festival is a traditional festival in ...

Apple Watch battery life is only one day? Apple says it will change

Apple did not disclose battery life for the Apple...

The Hengduan Mountains glaciers are precious because they are rare.

01 What is a glacier? Glaciers are a type of land...