1

我有两部分代码

预载

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

如果最后一个选项不正确,那么在调用 present 后我应该等待多长时间预加载?或者我应该听委托还是等待一些用户操作开始预加载?

4

1 回答 1

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]];
}
于 2013-03-31T00:14:01.463 回答