Skip to Main Content
Professional iPhone® and iPad™ Application Development
book

Professional iPhone® and iPad™ Application Development

by Gene Backlin
November 2010
Intermediate to advanced content levelIntermediate to advanced
600 pages
14h 21m
English
Wrox
Content preview from Professional iPhone® and iPad™ Application Development

Chapter 5. Touch Events

WHAT'S IN THIS CHAPTER?

  • How to handle touch events

  • How to create and handle gestures

  • How to simplify gesture recognition with the use of UIGestureRecognizer

With traditional desktop user interaction, events are initiated by the use of the keyboard or mouse. With iOS 4, touch and motion events are delivered to your application. The manager of these events is the UIApplication object and the actual event is a UIEvent object. The most common event that you will track in your application is the touch event interacting with views.

The UITouch sequence begins as soon as the user places a finger or fingers on the screen, and ends when the last finger has been removed from the screen. The location of the finger or fingers resolves itself to a touch point or CGPoint data value.

Touch events can be multi-fingered, as in the case of a pinch, when you zoom in or out on a photo. Single-fingered events can be the tap, the touch and hold, and the drag and swipe.

In this chapter you will observe two techniques of event handling that involve touches: The first uses touchesBegan, touchesMoved, touchesEnded and touchesCancelled, which are defined by iOS 4. The second, gesture recognition, uses the UIGestureRecognizer, which allows the customization of gestures in addition to the standard set.

TOUCH EVENT HANDLING

A touch event is a UIEvent of the type UIEventTypeTouches. The UITouch object represents the touches themselves and contains the following information:

  • locationInView — Coordinates ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional Visual Studio® 2010

Professional Visual Studio® 2010

Nick Randolph, David Gardner, Michael Minutillo, Chris Anderson
Navigating the Metaverse

Navigating the Metaverse

Cathy Hackl, Dirk Lueth, Tommaso Di Bartolo, John Arkontaky, Yat Siu
Navigating the Metaverse

Navigating the Metaverse

Cathy Hackl, Dirk Lueth, Tommaso Di Bartolo

Publisher Resources

ISBN: 9780470878194Purchase book