質問

In UIViews, the next responder is its superview by default. In my project, there's a scroll view and a small uiview as scroll view's child view. I want if I touch in the small view, the scroll view shouldn't move. Let the responder chain break at the child view.

I am trying by inheriting the child view, and override the - (UIResponder *)nextResponder method to return nil. But it has no effect.

Update: It seems that the child view didn't response to the Pan Gesture at all. When I scroll in child view, the - (UIResponder *)nextResponder method never called, but when I tap it, the method is called.

役に立ちましたか?

解決

Gesture recognisers and the classic responder chain are mutually exclusive within the same view subtree.

-nextResponder isn't called because events are taking the gesture recognition path rather than the responder chain path.

Just use a gesture recogniser to do whatever event handling you're trying to achieve in the small view.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top