I don't currently understand the approved solution to the problem linked below:
use a UITapGestureRecognizer instead. Check if recognizer.view != adBanner
Detect and ignore touches on iAd banners
I am having the same problem with a Sprite Kit game but in Swift and I am not sure how to implement the approved solution. Can someone provide a code example?
Here is my code:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in touches {
// If iAd banner has been tapped, do not start the game
// Else game starts
}
}
func adStopsGame(tapGesture: UITapGestureRecognizer) {
print("Game stopped")
}
You need to use bannerViewActionShouldBegin(_:willLeaveApplication:)
.
This method is called when the user taps the banner view. Your application controls whether the action is triggered. To allow the action to be triggered, return true. To suppress the action, return false. Your application should almost always allow actions to be triggered; preventing actions may alter the advertisements your application sees and reduce the revenue your application earns through iAd.
For a complete list of ADBannerView
delegate methods refer to: ADBannerViewDelegate Protocol Reference.