Search code examples
iosuiscrollviewtouchfirst-responder

responder chain goes subview to superview, what about scrollview?


From apple doc subview(near to the screen) gets to handle a touch event first than their superviews.

On the other hand, views are added to a scroll view as a subview but the scroll view handles touch to detect swipes first.

Can I treat the scrollview case as a special case?


Solution

  • Don't forget this part:

    If the hit-test view cannot handle the event, the event travels up the responder chain as described in “Responder Objects and the Responder Chain” until the system finds a view that can handle it.

    if your sub-view can't handle it, it will be passed to the UIScrollView.