Detecting Shakes Using Motion Events
When the iPhone detects a motion event, such as a shake, it passes that event to the current first responder, the primary object in the responder chain. Responders are objects that can handle events. All views and windows are responders, and so is the application object.
The responder chain provides a hierarchy of objects, all of which can respond to events. When an object toward the start of the chain handles an event, that event does not get passed further down. If it cannot handle it, that event can move on to the next responder.
An object may become the first responder by declaring itself to be so, via becomeFirst-Responder
. In this snippet, UIViewController
ensures that it becomes the first responder ...
Get The Core iOS Developer’s Cookbook, Fifth 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.