我有這些facebook插頁式廣告,當我在他們的GameScene中調用他們時,他們不顯示。當我在GameViewController中調用它們時,它們完美地工作,但不在我的GameScene中。有人能告訴我我的代碼在做什麼錯嗎?爲什麼我的插頁式廣告不能在我的GameScene中工作,而是在Swift的GameViewController中工作?
//GameViewController.swift
class GameViewController: UIViewController, FBInterstitialAdDelegate {
let interstitialFBAD: FBInterstitialAd = FBInterstitialAd(placementID: "65543456456456_454345345454534")
override func viewDidLoad() {
super.viewDidLoad()
}
//CALL THIS IN MY GAMESCENE.
func loadFBInterstitialAd() {
interstitialFBAD.delegate = self
interstitialFBAD.loadAd()
}
func interstitialAdDidLoad(interstitialAd: FBInterstitialAd!) {
interstitialFBAD.showAdFromRootViewController(self)
}
//GameScene.swift
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in touches {
let location = touch.locationInNode(self)
let node = self.nodeAtPoint(location)
if node.name == "retry" {
GameViewController().loadFBInterstitialAd()
}
}
}
好了,所以我嘗試了你的代碼,但廣告仍然彈不出來,我在控制檯中得到這個警告:警告:嘗試在上呈現,它已經呈現 –
coding22
沒關係它的作品!謝謝!! – coding22
賞金如果您的問題得到解決。至於'UIActivityController'警告,你是否顯示'UIActivityController'?如果是這樣,請確保在嘗試呈現廣告之前將其解除。 – uchiha