Lamikins
Lamikins

Reputation: 156

SpriteKit - iOS 7 - iAd Integration Error

I am trying to integrate iAd with my current sprite kit project. I have scoured existing questions, most of which say adding

self.canDisplayBannerAds = YES;

will get the ads to work. However, every time I try one of the solutions posted, I get this error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setShowsFPS:]: unrecognized selector sent to instance 0x14dbcc50'

In the storyboard, I have tried setting the view to SKView. I have added the iAd framework to the project.

Here is my viewWillLayoutSubviews method:

-(void)viewWillLayoutSubviews{
[super viewWillLayoutSubviews];

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

if(!skView.scene){
    // Create and configure the scene.
    SKScene * scene = [Intro sceneWithSize:skView.bounds.size];
    scene.scaleMode = SKSceneScaleModeAspectFill;

    // Present the scene.
    [skView presentScene:scene];

    self.canDisplayBannerAds = YES;
}
}

how should I solve this problem? Any and all suggestions are appreciated!

EDIT:

Here is a screenshot of my storyboard, with the view selected. I think this is how to change the view's class using storyboard. But I still get the same error.

enter image description here

Upvotes: 0

Views: 358

Answers (1)

Kaiser
Kaiser

Reputation: 688

You are not crashing due to the banner ads. You are crashing on the line

skView.showsFPS = NO;

because self.view is a UIView not a SKView.

Edit:

This appears to be a side effect of using UIViewController's iAD category extension. You can retrieve the SKView using the following:

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

Upvotes: 3

Related Questions