使用SpriteKit显示横幅广告 [英] Displaying banner ads with SpriteKit

查看:119
本文介绍了使用SpriteKit显示横幅广告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是SpriteKit的新手,刚刚发布了我的第一款游戏.现在,我想在游戏中添加横幅广告.但是,我完全迷路了.

I'm new to SpriteKit and just published my first game. Now I would like to add banner ads to the game. However, I'm completely lost.

大多数教程告诉您只需致电

Most tutorials tell you to simply call

self.canDisplayBannerAds = YES;

在viewDidLoad方法中.我正在这样做,并且我还导入了iAD.h并链接了所需的二进制文件.但是,每次我启动游戏时,它都会崩溃并出现以下错误:

in the viewDidLoad method. I'm doing that, and I also imported iAD.h and linked the required binaries. However, everytime I start the game it crashes and gives me the following error:

-[UIView presentScene:transition:]: unrecognized selector sent to instance 0x15e2dd00

有人知道如何正确地将iAD实施到Sprite Kit游戏中的好教程或任何想法吗? Apple Docs也不是真的有用.

Does anybody know a good tutorial or any ideas on how to correctly implement iADs into a Sprite Kit game? Apple Docs wasn't really helpful either.

推荐答案

我不久前才发现这个问题,因为我也完全迷失了!您需要做的是

I had honestly just figured this out not that long ago because I too was completely lost! What you need to do is

1:将iAd框架链接到您的项目

1: Link the iAd framework into your project

然后,转到您的ViewController类,然后在.m文件中,执行以下操作

Then, go to your ViewController class, and inside the .m file, do the following

#import <iAd/iAd.h>

- (void)viewDidLoad
{
[super viewDidLoad];

// Configure the view.
SKView * skView = (SKView *)self.originalContentView;
//skView.showsFPS = YES;
//skView.showsNodeCount = YES;

// Create and configure the scene.
SKScene * scene = [SKSceneClass sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;

self.canDisplayBannerAds = YES;

// Present the scene.
[skView presentScene:scene];
}

或如果您正在进行水平应用,则将viewDidLoad更改为viewWillLayoutSubviews

or if you are doing a horizontal application, change viewDidLoad with viewWillLayoutSubviews

仅此而已:) 希望有帮助!

That is all that is required :) Hope that helps!

这篇关于使用SpriteKit显示横幅广告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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