Detecting Shakes
To detect when the user is shaking the device, you could perform some intricate math on the signal that comes from the accelerometer. However, the class UIResponder has been kind enough to implement methods that do the math for you.
// Triggered when a shake is detected - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event; // Triggered when the shake is complete - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event; // Triggered when ...
Get iOS Programming: The Big Nerd Ranch Guide, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.