Skip to content

Instantly share code, notes, and snippets.

@casspangell
Created November 19, 2013 18:13
Show Gist options
  • Save casspangell/7549784 to your computer and use it in GitHub Desktop.
Save casspangell/7549784 to your computer and use it in GitHub Desktop.
Detect Shake in iOS
- (void)viewDidLoad
{
[super viewDidLoad];
[self becomeFirstResponder]; // set this view as first responder
}
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if(event.type == UIEventSubtypeMotionShake){
NSLog(@"SHAKE");
}
}
- (BOOL)canBecomeFirstResponder
{
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment