【问题标题】:iAd interstitial after UIWebView did finish loadUIWebView 完成加载后的 iAd 插页式广告
【发布时间】:2015-02-14 14:09:57
【问题描述】:

我只想在调用 webViewdidFinishLoad 后显示一次 iAd 插页式广告。

-(void)viewWillAppear:(BOOL)animated {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        [self cycleInterstitial];
        [self performSelector:@selector(presentInterlude) withObject:nil afterDelay:300]; 
    }
}

-(void)cycleInterstitial {
    // Clean up the old interstitial...
    interstitial.delegate = nil;
    // and create a new interstitial. We set the delegate so that we can be notified of when
    interstitial = [[ADInterstitialAd alloc] init];
    interstitial.delegate = self;
}

-(void)presentInterlude {
    // If the interstitial managed to load, then we'll present it now.
    if (interstitial.loaded) {
        NSLog(@"Loaded inter");
        [interstitial presentFromViewController:self];
    } else {
        NSLog(@"Not Loaded inter");   
    }
}

-(void)interstitialAdDidUnload:(ADInterstitialAd *)interstitialAd {
    [self cycleInterstitial];
}

-(void)interstitialAd:(ADInterstitialAd *)interstitialAd didFailWithError:(NSError *)error {
    NSLog(@"interstitialAd error: %@",error.description);
}

这可行,但我只想在webViewdidfinishload 之后显示一个 iAd 插页式广告。

【问题讨论】:

    标签: ios ipad iad interstitial


    【解决方案1】:

    这可以通过设置BOOL 来检查ADInterstitialAd 是否已经显示。

    @implementation ViewController {
        BOOL doNotShowAd;
    }
    
    -(void)viewWillAppear:(BOOL)animated {
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad  && doNotShowAd == NO) {
            [self cycleInterstitial];
            [self performSelector:@selector(presentInterlude) withObject:nil afterDelay:300];
            doNotShowAd = YES;
        }
    }
    

    【讨论】:

    • 是的,没错。如果用户打开应用程序并在 300 秒后显示一个新的 ADInterstitialAd 并且如果用户长时间关闭应用程序(主页按钮)并再次打开它,我想直接显示一个 ADInterstitialAd 广告并重新启动 300 秒。谁设置了 doNotShowAd = NO; ?还是我不需要这个?
    • 我该怎么办?如果我在没有终止的情况下关闭应用程序并将应用程序调用到前台而不是给我一个新的完整 iAdInterstitial?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多