How can I enable iAd when using Sprite Kit?

一世执手 提交于 2019-12-12 12:41:34

问题


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)?


回答1:


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/




回答2:


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;


来源:https://stackoverflow.com/questions/19740365/how-can-i-enable-iad-when-using-sprite-kit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!