O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required