Changes

Jump to: navigation, search

An Overview of iPhone Multitouch, Taps and Gestures

2 bytes removed, 20:37, 20 January 2011
no edit summary
In the chapter entitled Understanding iPhone Views, Windows and the View Hierarchy we spent some time talking about the view hierarchy of an appliation’s user interface and how that hierarchy also defined part of the application’s responder chain. In order to fully understand the concepts behind the handling of touch screen gestures it is first necessary to spend a little more time learning about the responder chain.
When the user interacts with the touch screen of an iPhone the hardware detects the physical contact and notifies the operating system. The operating system subsequently creates an event associated with the interfaction interaction and passes it into the application’s event queue where it is subsequently picked up the event loop and passed to the current first responder object; the first responder being the object with which the user was interacting when this event was triggered (for example a UIButton or UIView object). If the first responder has been programmed to handle the type of event received it does so (for example a button may have an action defined to call a particular method when it receives a touch event). Having handled the event, the responder then has the option of discarding that event, or passing it up to the next responder in the response chain (defined by the object’s nextResponder property) for further processing, and so on up the chain. If the first responder is not able to handle the event it will also pass it to the next responder in the chain and so on until it either reaches a responder that handles the event or it reaches the end of the chain (the UIApplication object) where it will either be handled or discarded.
Take, for example, a UIView with a UIButton subview. If the user touches the screen over the button then the button, as first responder, will receive the event. If the button is unable to handle the event it will need to be passed up to the view object. If the view is also unable to handle the event it would then be passed to the view controller and so on.
When working with the responder chain, it is important to note that the passing of an event from one responder to the next responder in the chain does not happen automatically. If an event needts needs to be passed to the next responder, code must be written to make it happen.
== Forwarding an Event to the Next Responder ==

Navigation menu