Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 2. Views > Gestures

Gestures

Views intercept user touches. This integration between the way things look and the way things react enables you to add a meaningful response to taps, drags, and what have you. Adding touch handlers like touchesBegan: withEvent: to your views allows you to intercept user touches, determine the phase of the touch (the equivalent of mouse down, mouse dragged, mouse up), and produce feedback based on those touches.

The UITouch class tells you where the event took place (locationInView:) and the tap count (tapCount), which is vital for distinguishing between single- and double-taps. Several recipes in this chapter demonstrate how to use these gesture responses and how to integrate view geometry and hierarchy into your applications for enticing, layered, direct-manipulation interfaces.