Rad'Val
Rad'Val

Reputation: 9251

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?

Upvotes: 6

Views: 2663

Answers (2)

FoJjen
FoJjen

Reputation: 774

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;
    }
}

Upvotes: 15

Arsalan Habib
Arsalan Habib

Reputation: 1395

It seems you need to use the NSNotificationCenter for the said task. Have a look at this tutorial.

Upvotes: -4

Related Questions