While most apple documents are very well written, I think 'Event Handling Guide for iOS' is an exception. It's hard for me to clearly understand what's been described there.
The document says,
In hit-testing, a window calls
hitTest:withEvent:
on the top-most view of the view hierarchy; this method proceeds by recursively callingpointInside:withEvent:
on each view in the view hierarchy that returns YES, proceeding down the hierarchy until it finds the subview within whose bounds the touch took place. That view becomes the hit-test view.
So is it like that only hitTest:withEvent:
of the top-most view is called by the system, which calls pointInside:withEvent:
of all of subviews, and if the return from a specific subview is YES, then calls pointInside:withEvent:
of that subview's subclasses?
I think you are confusing subclassing with the view hierarchy. What the doc says is as follows. Say you have this view hierarchy. By hierarchy I'm not talking about class hierarchy, but views within views hierarchy, as follows:
+----------------------------+
|A |
|+--------+ +------------+ |
||B | |C | |
|| | |+----------+| |
|+--------+ ||D || |
| |+----------+| |
| +------------+ |
+----------------------------+
Say you put your finger inside D
. Here's what will happen:
hitTest:withEvent:
is called on A
, the top-most view of the view hierarchy.pointInside:withEvent:
is called recursively on each view.
pointInside:withEvent:
is called on A
, and returns YES
pointInside:withEvent:
is called on B
, and returns NO
pointInside:withEvent:
is called on C
, and returns YES
pointInside:withEvent:
is called on D
, and returns YES
YES
, it will look down on the hierarchy to see the subview where the touch took place. In this case, from A
, C
and D
, it will be D
.D
will be the hit-test view