Search code examples
ios7sprite-kitiadadbannerviewskview

Pausing iAd Request Issue


So when my view controller loads I start sending adBanner requests..

- (void)viewDidLoad{

    [super viewDidLoad];

    self.canDisplayBannerAds = YES;

}

But I get an error when starting my scene for my game even though I set canDisplayBannerAds to NO... I have commented where the error begins through debugging

- (IBAction)startGame:(id)sender {

    NSLog(@"Start Game triggered");
    adBanner.hidden = 1;
    self.canDisplayBannerAds = NO;

    // Configure the view.
    // Configure the view after it has been sized for the correct orientation.
    skView = (SKView *)self.view;
    if (!skView.scene) {  // the error happens during this if statement
        skView.showsFPS = YES;
        skView.showsNodeCount = YES;

        // Create and configure the scene.
        theScene = [TCAMyScene sceneWithSize:skView.bounds.size];
        theScene.scaleMode = SKSceneScaleModeAspectFill;

        theScene.delegate = self;
        // Present the scene.
        [skView presentScene:theScene];

    }
}

The error:

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

What is the problem? And how do I resolve this?


Solution

  • Your view controller's self.view property is not a SKView, it's a UIView. You may have assigned the ad banner view as the view controller's view, or using iAd in the same view controller causes it to replace the SKView, or your Sprite Kit storyboards file doesn't use the SKView as it should.