Touch Delivery
Let’s now return to the very beginning of the touch reporting process, when the system sends the app a UIEvent containing touches, and tease apart in full detail the entire procedure by which a touch is delivered to views and gesture recognizers:
-
Whenever a new touch appears, the application calls the UIView instance method
hitTest:withEvent:
on the window, which returns the view (called, appropriately, the hit-test view) that will be permanently associated with this touch. This method uses the UIView instance methodpointInside:withEvent:
along withhitTest:withEvent:
recursively down the view hierarchy to find the frontmost view containing the touch’s location and capable of receiving a touch. The logic of how a view’suserInteractionEnabled
,hidden
, andopacity
affect its touchability is implemented at this stage. Each time the touch situation changes, the application calls its own
sendEvent:
, which in turn calls the window’ssendEvent:
. The window delivers each of an event’s touches by calling the appropriatetouches...
method(s), as follows:-
As a touch first appears, it is initially delivered to the hit-test view’s swarm of gesture recognizers. It is then also delivered to that view. The logic of withholding touches in obedience to
multipleTouchEnabled
andexclusiveTouch
is also implemented at this stage. For example, additional touches won’t be delivered to a view if that view currently has a touch and hasmultipleTouchEnabled
set to NO. If a gesture is recognized ...
-
As a touch first appears, it is initially delivered to the hit-test view’s swarm of gesture recognizers. It is then also delivered to that view. The logic of withholding touches in obedience to
Get Programming iOS 6, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.