How to enable iAd when using Sprite Kit?

In iOS 7, we can enable iAd very easily when using:

self.canDisplayBannerAds = YES;

in code ViewDidLoad UIViewController

However, I cannot use this in my ViewController (ViewControl, which loads SKScene). My game fails to load.

So, how can I activate iAd in my game (using the Sprite Kit)?

+3
source share
2 answers

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

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

+3
source

Perhaps you are accessing the view property. When using iAds, you need to replace .view with .originalContentView. For instance:

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

replaced by

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

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


All Articles