多次显示admob间质如何? [英] Displaying admob interstitals multiple times how?

查看:92
本文介绍了多次显示admob间质如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小型游戏应用程序,其中只有一个情节提要,并且在其中创建了诸如开始菜单-游戏区分数之类的场景,我在其中添加了admob标语视图和插页式广告。我的标语视图工作正常,但插页式广告仅适用于一个时间。

I have small gaming app which has one storyboard and inside it creates scenes like start menu-gamin area-scores I have added admob banner view and interstitals into it.My banner view is working fine and but my interstitial only works for one time.

我将插页式广告加载到viewdidload上,并在调用游戏会话结束的函数中将其触发,正如我所说的那样,但仅在用户启动时一次

I load my interstitial on my viewdidload and fire it in the function which calls the gaming sessions end and as I say it works but only for one time when user starts another game and fails this time there is no interstital(error below).So what should I do to fix it I want my game to show interstitials multiple times whenever I want.



错误:
请求错误:由于使用了插页式对象,因此不会发送请求。

Error : Request Error: Will not send request because interstitial object has been used.

标题:

#import "GADBannerView.h"
#import "GADInterstitial.h"
@class GADInterstitial;
@class GADRequest;
////////////code UIviewcontroller//////////
        GADBannerView *bannerView_;
        GADInterstitial *interstitial_;

实施

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

}

实施

-(void)failgame
{
//////////////////gaming code///////////

    [interstitial_ presentFromRootViewController:self];

}

在googleadmob SDK页面上,它说插页是一次性的对象,所以我%100肯定是问题所在,但是没有什么可以解释如何多次调用它们的,所以只要您指出答案,请不要告诉我已阅读5次。

On googleadmob SDK page it says that interstials are one time use objects so I am %100 sure that is the problem but there is nothing there to explain how to call them multiple time's so as long as you point the answer please don't tell go read it I have read it 5 times.

推荐答案

没有人给出答案,但是我敢肯定,还有其他人也有同样的问题,所以对于那些想要

Well no one gave an answer but I am sure that there are some others out there who had the same problem so for those who want to call interstitals multiple times here is the trick.

将其放入您自己的方法中,并从您的main方法中调用方法(可多次回复)

Put it into its own method and call method from your main method (which replies many times)

将空隙保留在viewdidload上(或先要放火的地方),因为如果不这样做,那么您会错过第一次放火的机会。

Keep the interstitals on your viewdidload (or where you want fire first) because if you don't then you miss the first fire the others will work.

完整代码。

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

    }

}

我把随机数数字创建以及是否存在,因为我不希望用户每次都调用int时就会看到这些插页式广告,因此每次触发的机会都是4/1,因此它会在4-5的插曲中显示1个插页式广告。

I put random number creation and if there because I don't want users to see those intersitials every time even call int is fired every time there is 4/1 chance for it to fire so it shows 1 interstitial for 4-5 fire.

这篇关于多次显示admob间质如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆