Question

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;

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

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.

Was it helpful?

Solution

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

1: Link the iAd framework into your project

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

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top