Search code examples
iosobjective-csprite-kitiadinterstitial

Getting an error with Interstitial Ads (iAd and Spritekit)


I keep getting an error within this section of code:

// Interstitial iAd
-(void)showFullScreenAd {
    // Check if already requesting ad
    if (requestingAd == NO) {
        interstitial = [[ADInterstitialAd alloc] init];
        interstitial.delegate = self;
        self.interstitialPresentationPolicy = ADInterstitialPresentationPolicyManual;
        [self requestInterstitialAdPresentation];
        NSLog(@"interstitialAdREQUEST");
        requestingAd = YES;
    }
}

-(void)interstitialAd:(ADInterstitialAd *)interstitialAd didFailWithError:(NSError *)error {
    interstitial = nil;
    requestingAd = NO;
    NSLog(@"interstitialAd didFailWithERROR");
    NSLog(@"%@", error);
}

-(void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd {
    NSLog(@"interstitialAdDidLOAD");
    if (interstitialAd != nil && interstitial != nil && requestingAd == YES) {
        //[interstitial presentFromViewController:self];
        //[interstitial presentInView:self.view] // I get an error on this line
        NSLog(@"interstitialAdDidPRESENT");
        if (interstitial.loaded) {
            [self requestInterstitialAdPresentation]; //I also get an error on this line too
        }
    }
}

-(void)interstitialAdDidUnload:(ADInterstitialAd *)interstitialAd {
    interstitial = nil;
    requestingAd = NO;
    NSLog(@"interstitialAdDidUNLOAD");
}

-(void)interstitialAdActionDidFinish:(ADInterstitialAd *)interstitialAd {
    interstitial = nil;
    requestingAd = NO;
    NSLog(@"interstitialAdDidFINISH");
}

Its something to do with this particular line:

[self requestInterstitialAdPresentation];

This is the error I'm getting and I have no idea what this line needs changing to so that the error stops:

-[UIView setShowsFPS:]: unrecognized selector sent to instance 0x146e241a0

Ive gotten this error in the past when working with the same sort of code, it usually appears when I start trying to implement interstitial ads. I seem to be having a lot of trouble trying to implement interstitial ads and I have read a lot of tutorials. I have no idea what I'm doing wrong :( can someone please help?

Regards,

Ryan


Solution

  • setShowsFPS: is a method on SKView, but not on UIView.

    Although I don't see the cause in the code you posted, the error means that a UIView instance is being passed to a method that expects an SKView. Set an exception breakpoint to try to figure out where. It's possible that it isn't your code that's triggering the call.