Motion Events

In Chapter 5, we briefly talked about UIView’s superclass, UIResponder. Instances of UIResponder can become the first responder of the window and will receive events when the device is shaken or a key is pressed on the keyboard. You will make the instance of HypnosisView the first responder of Hypnosister’s window. Shaking the device will send a message to the HypnosisView, and that method will change its circleColor.

To give a UIResponder first responder status, you send it the message becomeFirstResponder. In HypnosisterAppDelegate.m, tell the HypnosisView instance to become the first responder. The becomeFirstResponder method returns a Boolean value indicating whether the receiving object successfully became the first responder ...

Get iOS Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.