I touch an iAd and Xcode recognizes I also touched the background

24 views Asked by At

I have a game where I have an ad on the top. My game has an action that is triggered whenever the user touches the background. It just so happens that when I click my ad, the said action is triggered, as if I had just touched the background! Any ideas on a fix to this problem? Thank you!

1

There are 1 answers

0
Doro On

Set your UIGestureRecognizer delegate and implement UIGestureRecognizerDelegate method gestureRecognizer:shouldReceiveTouch:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if (touch.view == iAdView) { 
            return NO;
    }
    return YES;
}

This code excludes target view from UIGestureRecognizer.

Do not forget to set userInteractionEnabled property to YES for your iAdView