iOS Reference Library Apple Developer
Search

About Events in iOS

Events are objects sent to an application to inform it of user actions. In iOS, events can take many forms: multitouch events, motion events—for example, from device accelerometers—and events for controlling multimedia. (This last type of event is known as a remote-control event because it originates from a headset or other external accessory.)

image: ../Art/events_to_app.jpg

The UIKit and Core Motion frameworks are responsible for event propagation and delivery in iOS.

At a Glance

An Application Receives Multitouch Events When Users Touch its Views

The Multi-Touch interface of iPhones, iPads, and iPod touches generates low-level events when users touch views of an application. The application sends these events (as UIEvent objects) to the view on which the touches occurred. That view typically analyzes the touches represented by each event object and responds in an appropriate manner.

Applications are frequently interested in interpreting the touches a user makes as a common gesture, such as a tap or swipe gesture. These applications can make use of UIKit classes called gesture recognizers, each of which is designed to recognize a specific gesture.

Relevant Chapters:: ‚ÄúEvent Types and Delivery,‚Äù ‚ÄúMultitouch Events,‚Äù ‚ÄúGesture Recognizers‚Äù

An Application Receives Motion Events When Users Move the Device

Motion events come in different forms, and you can handle then using different frameworks. When users shake the device, the UIKit delivers a UIEvent object to an application; these shaking-motion events are gestures often used to trigger undo and redo actions. If you want your application to receive high-rate, continuous accelerometer and gyroscope data, use the Core Motion framework. (Only certain devices have a gyroscope.) You may also use the UIAccelerometer class to receive and handle accelerometer data.

Relevant Chapters:: ‚ÄúEvent Types and Delivery,‚Äù ‚ÄúMotion Events‚Äù

Remote-Control Events Are Sent When Users Manipulate Multimedia Controls

By conforming to an Apple-provide specification, headsets and other external accessories can send (via the UIKit framework) remote-control events to an application capable of playing audio or video. The view hosting the multimedia can receive the events and thereby control the audio video according to the user’s command (for example, pausing or fast-forwarding).

Relevant Chapters:: ‚ÄúEvent Types and Delivery,‚Äù ‚ÄúRemote Control of Multimedia‚Äù

How to Use this Book

Regardless of the type of event you’re interested in, you should first read “Event Types and Delivery.” This chapter provides essential background information.

See Also

Some iPhones and other devices have GPS and compass hardware that also generate low-level data delivered to an application for processing. Location Awareness Programming Guide discusses how to receive and handle this data.

Many sample code projects in the iOS Reference Library have code that illustrates the handling of multitouch events and the use of gesture recognizers. Among these are the following projects: Touches, Metronome, CopyPasteTile, and SimpleGestureRecognizers.




Last updated: 2010-08-03

Did this document help you? Yes It's good, but... Not helpful...