Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass a touch event from a UIView to the UIView(s) beneath it?

A simple problem but I can't find a solution for it:

I have 2 UIViews, one above the other in the same parent view. Both have GestureRecognizers on them but only the top most is receiving the events. How can I make the top most view pass all the gestures he gets to the other UIViews beneath it?

like image 282
Rad'Val Avatar asked Sep 11 '11 20:09

Rad'Val


1 Answers

This is how i pass touches...

Subclass the uiview and add

-(id)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    UIView *hitView = [super hitTest:point withEvent:event];
    if (hitView == self){
        return nil;
    }
    else {
        return hitView;
    }
}
like image 168
FoJjen Avatar answered Nov 13 '22 15:11

FoJjen