作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已成功为我的 iOS 应用集成插页式广告。我知道在那个广告 View 上有一个关闭按钮,我们可以在点击该按钮后关闭它。
但我想在 3 秒后以编程方式关闭此广告 View 。但是我不知道关闭这个广告的方法是什么。
----- 已更新-----
- (void)viewDidLoad
{
[super viewDidLoad];
singletonClassObject=[Singleton SharedManager];
//--------ADMOB FULLSCREEN----------
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.delegate = self;
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.adUnitID = @"ca-app-pub-3940256099942544/4411468910";
GADRequest *request = [GADRequest request];
// Requests test ads on simulators.
request.testDevices = @[ GAD_SIMULATOR_ID, @"MY_TEST_DEVICE_ID" ];
[self.interstitial loadRequest:request];
//--------END OF AD MOB FULLSCREEN---------
}
这是在点击事件中展示广告的方式
if ([self.interstitial isReady]) {
[self.interstitial presentFromRootViewController:self];
}
这些是在应用关闭、显示等时触发的代表
/// Called when an interstitial ad request succeeded.
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad {
NSLog(@"interstitialDidReceiveAd");
}
/// Called when an interstitial ad request failed.
- (void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@"interstitialDidFailToReceiveAdWithError: %@", [error localizedDescription]);
}
/// Called just before presenting an interstitial.
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad {
NSLog(@"interstitialWillPresentScreen");
}
/// Called before the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
NSLog(@"interstitialWillDismissScreen");
//[viewAdd removeFromSuperview];
[self.view removeFromSuperview];
}
/// Called just after dismissing an interstitial and it has animated off the screen.
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad {
NSLog(@"interstitialDidDismissScreen");
[self.view removeFromSuperview];
}
/// Called just before the application will background or terminate because the user clicked on an
/// ad that will launch another application (such as the App Store).
- (void)interstitialWillLeaveApplication:(GADInterstitial *)ad {
NSLog(@"interstitialWillLeaveApplication");
}
最佳答案
虽然没有记录,但我发现可以通过以下方式关闭插页式广告:
[self dismissViewControllerAnimated:YES completion:NULL];
调用显示插页式广告的 ViewController
逆向工程,Interstitial必须由presentViewController:animated:completion呈现:
关于ios - 如何在 ios 中以编程方式关闭插页式广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26229554/
我是一名优秀的程序员,十分优秀!