Display banner ads using 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 am completely lost.

In most tutorials you just need to call

self.canDisplayBannerAds = YES; 

in the viewDidLoad method. I do this and I also imported iAD.h and linked the necessary binaries. However, every time I launch the game, it crashes and gives me the following error:

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

Does anyone know a good tutorial or any ideas on how to properly integrate iADs into a Sprite Kit game? Apple Docs didn't help either.

+4
source share
1 answer

I honestly just thought about it not so long ago, because I, too, was completely lost! What you need to do is

1: associate your iAd infrastructure with your project

Then go to the 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 running a horizontal application, change viewDidLoad to viewWillLayoutSubviews

That's all it takes :) Hope this helps!

+4
source

Source: https://habr.com/ru/post/1210514/


All Articles