Bug*_*zer 4 iphone xcode objective-c admob ios
我有一个小游戏应用程序,它有一个故事板,里面创建场景,如开始菜单 - gamin区域 - 得分我添加了admob横幅视图和interstitals到它.我的横幅视图工作正常,但我的插页式广告只能工作一次.
我在我的viewdidload上加载我的插页式广告并在调用游戏会话结束的函数中激活它,正如我所说它有效,但只有一次当用户启动另一个游戏时失败,这次没有interstital(下面的错误).那么什么我应该怎么做才能修复它我想让我的游戏在我想要的时候多次显示插页式广告.
错误:请求错误:由于已使用插页式对象,因此无法发送请求.
标题:
#import "GADBannerView.h"
#import "GADInterstitial.h"
@class GADInterstitial;
@class GADRequest;
////////////code UIviewcontroller//////////
GADBannerView *bannerView_;
GADInterstitial *interstitial_;
Run Code Online (Sandbox Code Playgroud)
履行
-(void)viewdidload
{
//////////////////gaming code///////////
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.delegate = self;
interstitial_.adUnitID = @"ca-app-pub-6280395701552972/5217388242";
GADRequest *request = [GADRequest request];
[interstitial_ loadRequest:request];
}
Run Code Online (Sandbox Code Playgroud)
Implementaion
-(void)failgame
{
//////////////////gaming code///////////
[interstitial_ presentFromRootViewController:self];
}
Run Code Online (Sandbox Code Playgroud)
在googleadmob SDK页面上,它说intertials是一次性使用对象所以我%100肯定是问题,但没有什么可以解释如何多次调用它们所以只要你指出答案请不要告诉go读它我读过5次.
好吧,没有人给出答案,但我确信还有其他一些人有同样的问题,所以对于那些想要多次调用间隙的人来说就是诀窍.
将它放入自己的方法并从main方法调用方法(多次回复)
保持你的viewdidload(或你想先开火的地方)的间隙,因为如果你没有,那么你会错过第一次火,其他人将工作.
完整的代码.
- (void) callint
{
int rNumber1 = arc4random() % 45 + 1;
int rNumber2 = arc4random() % 45 + 1;
if((rNumber1%2==1) && (rNumber1%1==0))
{
[interstitial_ presentFromRootViewController:self];
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.delegate = self;
interstitial_.adUnitID = @"ca-app-pub-6280395701552972/5217388242";
GADRequest *request = [GADRequest request];
[interstitial_ loadRequest:request];
}
}
Run Code Online (Sandbox Code Playgroud)
我把随机数创建,如果那里因为我不希望用户每次看到那些间隔,甚至调用int每次有4/1的机会被触发,所以它显示1个插页式4-5火.