Erik Sapir
Erik Sapir

Reputation: 24767

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

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?

Upvotes: 0

Views: 292

Answers (1)

Erik Sapir
Erik Sapir

Reputation: 24767

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

Upvotes: 1

Related Questions