Created
January 3, 2013 19:28
-
-
Save jeffremer/4446282 to your computer and use it in GitHub Desktop.
How to detect shake gestures in a UIViewController.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation ViewController | |
#pragma mark - UIResponder | |
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event | |
{ | |
if (motion == UIEventSubtypeMotionShake) { | |
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Shaken" | |
message:@"Not stirred." | |
delegate:self | |
cancelButtonTitle:@"OK" | |
otherButtonTitles:nil]; | |
[alertView show]; | |
} | |
} | |
- (BOOL)canBecomeFirstResponder | |
{ | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment