2

In iPhone App How to implement shake gesture?

Please Help and suggest.

Thanks

ios
  • 6,134
  • 20
  • 71
  • 103

3 Answers3

2

If your ViewController enable first responder

[self becomeFirstResponder]

and implement motionEnded:withEvent:

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    if (event.type == UIEventSubtypeMotionShake) {
        NSLog(@"Shake is detected");  
    }
}
Tibidabo
  • 21,461
  • 5
  • 90
  • 86
1

Find it here How do I detect when someone shakes an iPhone?

Community
  • 1
  • 1
Ved
  • 612
  • 6
  • 10
0

Look at the docs to UIResponder and the UIEventSubtypeMotionShake event (from this answer to another SO question).

Community
  • 1
  • 1
Wolfram
  • 8,044
  • 3
  • 45
  • 66