1

I get the following error when I try to ad iAds to my SpriteKit game. Anyone know why this is?

-[UIView scene]: unrecognized selector sent to instance 0x10da31fb0

ViewController.m

- (void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];

    // Configure the view.
    SKView * skView = (SKView *)self.view;
    if (!skView.scene) {
        skView.showsFPS = NO;
        skView.showsNodeCount = NO;

        // Create and configure the scene.
        SKScene * scene = [HomeScreen sceneWithSize:skView.bounds.size];
        scene.scaleMode = SKSceneScaleModeAspectFill;
        // Present the scene.
        [skView presentScene:scene];

        self.canDisplayBannerAds = YES;
    }
}
Apollo
  • 8,384
  • 30
  • 97
  • 186
  • we had this many times before, the iAd view is replacing the view controller's view (dunno how though), which should be an SKView and not an iAd view – LearnCocos2D Mar 20 '14 at 22:23
  • @LearnCocos2D Ah I see. So what exactly is the solution? – Apollo Mar 20 '14 at 22:24
  • 1) If you go only IOS7 you can use canDisplayBannerAds but in this case no need to alloc ADBannerView. (except medium rectangle ad) http://www.techotopia.com/index.php/Integrating_iAds_into_an_iOS_7_App 2) If you dont develop exclusively to IOS7 then you do the ADBannerView view creation. More info on 1) regarding view hierarchy modification eg here: http://stackoverflow.com/questions/19521677/what-does-the-iad-uiviewcontroller-category-candisplaybannerads-do – nzs Mar 21 '14 at 00:13
  • @codedad I do in fact only need to support iOS7+, however your #1 solution still causes my app to throw the same error. Are you sure that that works? I've edited my question as well... – Apollo Mar 21 '14 at 01:22

1 Answers1

0

In addition to my comment (regarding iAD) the error shows me that somehow to view's class is not correct. It should be SKView.

To correct this go to Interface Builder and for that particular view change the class using the Identity inspector (3rd "tab") to SKView.

It happened to me when manually created from the scratch a SpriteKit project.

Hope it helps! :)

nzs
  • 3,232
  • 16
  • 22