Changes

Jump to: navigation, search

An Overview of iOS 4 iPhone Multitouch, Taps and Gestures

3,027 bytes removed, 20:53, 20 January 2011
no edit summary
Gesture is an umbrella term used to encapsulate any single interaction between the touch screen and the user between, starting at the point that the screen is touched (by one or more fingers) and the time that the last finger leaves the surface of the screen. Swipes, pinches, stretches and flicks are all forms of gesture.
 
== Taps ==
 
A tap, as the name suggests, occurs when the user touches the screen with a single finger and then immediately lifts it from the screen. Taps can be single-taps or multiple-taps and the event will contain information about the number of times a user tapped on the screen.
 
== Touches ==
 
A touch occurs when a finger establishes contact with the screen. When more than one finger touches the screen each figure registers as a touch up to a maximum of five fingers.
 
== Touch Notification Methods ==
 
Touch screen events cause one of four methods on the first responder object to be called. The method that gets called for a specific event will depend on the nature of the interaction. In order to handle events, therefore, it is important to ensure that the appropriate methods from those outlined below are implemented within your responder chain. These methods will be used in the worked example contained in the [[iOS 4 Phone Multitouch, Tap and Gesture Event Handling Tutorial]] and [[Detecting iOS 4 iPhone Touch Screen Gesture Motions]] chapters of this book:
 
=== touchesBegan method ===
 
The touchesBegan method is called when the user first touches the screen. Passed to this method are an argument called touches of type NSSet and the corresponding UIEvent object. The touches object contains a UITouch event for each finger in contact with the screen. The tapCount method of any of the UITouch events within the touches set can be called to identify the number of taps, if any, performed by the user. Similarly, the coordinates of an individual touch can be identified from the UITouch event either relative to the entire screen or within the local view itself.
 
=== touchesMoved method ===
 
The touchesMoved method is called when one or more fingers move across the screen. As fingers move across the screen this method gets called multiple times allowing the application to track the new coordinates and touch count at regular intervals. As with the touchesBegan method, this method is provided with an event object and an NSSet object containing UITouch events for each finger on the screen.
 
=== touchesEnded method ===
 
This method is called when the user lifts one or more fingers from the screen. As with the previous methods, touchesEnded is provided with the event and NSSet objects.
 
=== touchesCancelled method ===
 
When a gesture is interrupted due to a high level interrupt, such as the phone detecting an incoming call, the touchesCancelled method is called.
 
== Summary ==
 
In order to fully appreciate the mechanisms for handling touch screen events within an iOS 4 iPhone application, it is first important to understand both the responder chain and the methods that are called on a responder depending on the type of interaction. We have covered these basics in this chapter. In the next chapter, entitled iOS 4 Phone Multitouch, Tap and Gesture Event Handling Tutorial we will use these concepts to create an example application that demonstrates touch screen event handling. 
 
 
== Taps ==

Navigation menu