如何显示多个Admob插页式广告?

时间:2013-03-15 17:01:42

标签: admob interstitial

我有两部分代码

预压

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

显示

[interestial presentFromRootViewController:]

我该怎么做才能在下次正确显示插页式广告? 使用ARC而不使用

预压

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];

如果最后一个选项不正确,那么我应该等待多长时间才能预先加载?或者我应该听代表还是等待某些用户操作开始预加载?

1 个答案:

答案 0 :(得分:10)

您应该从GADInterstitialDelegate收听interstitialDidDismissScreen:方法。这将告诉你当你完成第一个插页式广告时,你可以开始为下一个插页式广告做准备。

所以你会有类似的东西:

// 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]];
}
相关问题