weezor
weezor

Reputation: 2631

Make UIGestureRecognizer to receive touches started on subviews

I attached a custom UIGestureRecognizer to one UIView which fills almost the whole screen. This view contains a small subview which needs to receive normal touches as well.

Problem: Touches started on this subview are not handled by the recognizer attached to its parent.

I want the gestureRecognizer to be first priority and work even if the subview is touched. How can I forward all touches started on this subview to its parent as well in order that my gestureRecognizer can do its job?

Upvotes: 1

Views: 3031

Answers (1)

weezor
weezor

Reputation: 2631

I found the solution! It's actually quite simple.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
     // Forward this message up the responder chain
     [super touchesBegan:touches withEvent: event];
}

The call to super in touchBegan of the subview is all it takes. Found it on this blog Allow superview to recieve events caught by subview

Upvotes: 4

Related Questions