iOS - prevent click on UIButton from propagating to views behind it

286 Views Asked by At

I have a button on top of a GLKView. When i click on the button, i also receive a long touch notification on the GLKView that is behind the button.

How can i prevent the notification from propagating to the view?

1

There are 1 best solutions below

0
Erik Sapir On

Found the solution to my question. The following code will do the trick:

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    UIView* viewRceivingTouch = touch.view;

    return (viewRceivingTouch == self.glkView);
}