3
votes

In IOS 7, we can enable iAd very easy when using:

self.canDisplayBannerAds = YES;

in code ViewDidLoad of UIViewController

However, I cannot use this in my ViewController (the ViewControl that load SKScene). My game is crash when loading.

So how can I active iAd in my game (using Sprite Kit)?

2
I need my game in Landscape so I add this in: - (void)viewWillLayoutSubviews but it will be crashed.However, if i give it in viewDidLoad, this game will be portrait. When I can add this code self.canDisplayBannerAds = YES; to enable iAD?Huygamer

2 Answers

3
votes

You can only show iAd in a UIViewController subclass. You are doing it right. Put the following code in your UIViewController and not in the SKScene.

Please refer to this tutorial for the exact code: http://tutorials.veasoftware.com/2013/10/10/how-to-add-iads/

0
votes

It's possible that you are accessing the view property. When using iAds you need to replace .view with .originalContentView. For example:

SKView* skView = (SKView *)self.view;

is replaced with

SKView* skView = (SKView *)self.originalContentView;