2013-03-15 58 views
1

我有代碼如何顯示多個Admob插頁式廣告?

預緊力兩個部分

interestial = [[GADInterstitial alloc] init]; 
[interestial loadRequest:request] 

顯示

[interestial presentFromRootViewController:] 

我應該怎麼辦間質性下一次正常顯示? 弧和沒有

預緊

if(arc) [interstitial release]; 
interstitial = [[GADInterstitial alloc] init]; 
[interstitial loadRequest:request] 

顯示

[interstitial presentFromRootViewController:self] 

- 或

初始化

interstitial = [[GADInterstitial alloc] init]; 

預緊

[interstitial loadRequest:request] 

顯示

[interstitial presentFromRootViewController:self] 

- 或

初始化

interstitial = [[GADInterstitial alloc] init]; 
[interstitial loadRequest:request]; 

預緊

// nothing 

顯示

[interstitial presentFromRootViewController:self]; 
[interstitial loadRequest:request]; 

如果最後一個選項不正確,那麼在現在被調用後需要多長時間等待預加載?或者我應該聽取代表或等待某些用戶操作來開始預加載?

回答

10

您應該聽取從GADInterstitialDelegateinterstitialDidDismissScreen:方法。這會告訴您何時完成第一個插頁式廣告,然後您就可以開始爲下一個插頁做準備。

所以你必須是這樣的:

// During init time. 
self.interstitial = [[GADInterstitial alloc] init]; 
self.interstitial.adUnitID = MY_INTERSTITIAL_UNIT_ID; 
self.interstitial.delegate = self; 
[self.interstitial loadRequest:[GADRequest request]]; 

... 


// During show time. 
[self.interstitial presentFromRootViewController:self]; 

... 

// When user dismisses the interstitial. 
- (void)interstitialWillDismissScreen:(GADInterstitial *)interstitial { 
    self.interstitial.delegate = nil; 
    if (!arc) { 
    [self.interstitial release]; 
    } 

    // Prepare next interstitial. 
    self.interstitial = [[GADInterstitial alloc] init]; 
    self.interstitial.adUnitID = MY_INTERSTITIAL_UNIT_ID; 
    self.interstitial.delegate = self; 
    [self.interstitial loadRequest:[GADRequest request]]; 
} 
+0

在iOS AdMob插頁事件的更新的指南可以在這裏找到:https://developers.google.com/admob/ios/interstitial#ad_events – 2017-09-24 03:44:15

相關問題