【问题标题】:Getting an error with Interstitial Ads (iAd and Spritekit)插页式广告(iAd 和 Spritekit)出现错误
【发布时间】:2015-11-01 13:40:57
【问题描述】:

我在这部分代码中不断收到错误:

// 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");
}

它与这个特定的行有关:

[self requestInterstitialAdPresentation];

这是我遇到的错误,我不知道该行需要更改什么才能停止错误:

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

我过去在使用相同类型的代码时遇到过此错误,通常在我开始尝试实施插页式广告时出现。我似乎在尝试实施插页式广告时遇到了很多麻烦,我已经阅读了很多教程。我不知道我做错了什么:(有人可以帮忙吗?

问候,

瑞恩

【问题讨论】:

    标签: ios objective-c sprite-kit iad interstitial


    【解决方案1】:

    setShowsFPS:SKView 上的方法,但不是 UIView 上的方法。

    虽然我在您发布的代码中看不到原因,但该错误意味着 UIView 实例正在传递给需要 SKView 的方法。设置一个异常断点来尝试找出在哪里。触发调用的可能不是您的代码。

    【讨论】:

    • 谢谢你的回答老兄!您所说的“可能不是您的代码触发了调用”是什么意思。还能是什么?你也碰巧有任何使用插页式广告的精灵套件的源代码吗?我在这方面遇到了很多麻烦,这让我发疯了 xD
    • 有人打电话给-setShowsFPS:(可能是view.showsFPS = ...)。你在整个项目的任何地方都这样做吗?如果是这样,请暂时添加一个NSAssert([myview isKindOfClass:[SKView class]]) 来追踪它。如果你从不调用它,你应该怀疑你看不到的代码。你试过异常断点吗?
    • 是的,因为它是Sprite kit项目所以默认调用它:
    • - (void)viewDidLoad { [super viewDidLoad]; // 配置视图。 SKView * skView = (SKView )self.view; skView.showsFPS = 否; skView.showsNodeCount = 否; skView.showsPhysics = 否; / Sprite Kit 应用额外的优化来提高渲染性能 */ skView.ignoresSiblingOrder = YES; // 创建和配置场景。 GameScene *scene = [GameScene unarchiveFromFile:@"GameScene"];场景.scaleMode = SKSceneScaleModeAspectFill;场景.size = skView.bounds.size; [skView presentScene:scene]; }
    • skView.showsFPS = NO 调用之前设置一个断点。确保 skView 确实是 SKView 而不仅仅是普通的旧 UIView
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多