【发布时间】:2014-06-22 10:53:17
【问题描述】:
我在我的 iOS 应用上使用 admob 插页式广告。 我只能显示一次插页式广告,任何进一步显示新插页式广告的请求都会失败(顺便说一下,永远不会调用委托)。
我的代码如下:
-(void) viewDidLoad
{
[super viewDidLoad];
[self allocateAndDisplayAd];
}
-(void) allocateAndDisplayAd
{
splashInterstitial_ = [[GADInterstitial alloc] init];
splashInterstitial_.adUnitID = @"ca-app-pub-MY-ID";
splashInterstitial_.delegate = self;
GADRequest *requestInterstitial = [GADRequest request];
[splashInterstitial_ loadRequest: requestInterstitial];
}
// below functions delegate are never triggered when requesting a new interstitial !!
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad
{
[splashInterstitial_ presentFromRootViewController: self];
}
- (void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error
{
splashInterstitial_ = nil;
}
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad
{
splashInterstitial_ = nil;
}
应用启动时插页式广告会正确显示(从 viewDidLoad 完成请求),然后任何新请求(调用 allocateAndDisplayAd)都会失败(没有错误消息,从未调用委托函数)。
我试图设置 splashInterstitial_ = nil;所以我确信下一个请求会重新分配一个新的插页式广告,但无法显示多个广告。
任何帮助将不胜感激。 谢谢
【问题讨论】:
-
首先:确保
splashInterstitial_在使用后必须被dealloc(你可以覆盖GADInterstitial类来确定)。第二:你在哪里声明splashInterstitial_? -
您好我在 Xcode 中使用 arc 是我无法使用释放功能。 splashInterstitial_ = nil;应该释放对象。对象 splashInterstitial_ 在我的视图控制器的 .h 中声明。感谢您的回答杰罗姆
-
您是否收到任何错误?
-
不,正如我在原帖中提到的,不再调用委托函数。
-
您何时以及如何致电
allocateAndDisplayAd?
标签: ios admob interstitial