如上用戶說你需要調用
adBanner.delegate = self
在viewDidLoad中
和落實代表在你的場景中處理不同的旗幟狀態。可能最容易使用擴展來保持代碼清潔。
//Delegates AdMob Banner
extension GameScene: GADInterstitialDelegate {
func adViewDidReceiveAd(bannerView: GADBannerView!) {
print("AdMob banner did load, showing")
// animate banner into your view/scene
}
func adViewWillPresentScreen(bannerView: GADBannerView!) {
print("AdMob banner clicked")
// pause game if needed as ad was pressed
}
func adViewDidDismissScreen(bannerView: GADBannerView!) {
print("AdMob banner closed")
// banner closed
}
func adView(bannerView: GADBannerView!, didFailToReceiveAdWithError error: GADRequestError!) {
print("AdMob banner error")
// handle error, hide from view etc
}
}
我做了一個廣告助手專門爲spriteKit,你可能會發現它有用 https://github.com/crashoverride777/Swift2-iAds-AdMob-CustomAds-Helper