ios - 插页式实现

标签 ios objective-c admob uiwindow

对于我公司的大多数应用程序,我们都会显示插页式广告。 首先我们加载它,当它加载时,我们显示它。

有时(很少)在过渡过程中出现插页式广告(例如 pushviewcontroller)。

我想知道在层次 View Controller 的另一个窗口中显示插页式广告是否是一个好的解决方案。

做类似的事情:

- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial {
    mWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    UIViewController* controller = [[UIViewController alloc] init];
    controller.view.backgroundColor = [UIColor clearColor];
    mWindow.backgroundColor = [UIColor clearColor];
    mWindow.rootViewController = controller;
    [mWindow makeKeyAndVisible];
    [self.interstitial presentFromRootViewController:mWindow.rootViewController];
}

- (void) interstitialDidDismissScreen:(GADInterstitial *)ad {
    [mWindow removeFromSuperview];
    mWindow = nil;
}

丑吗?

最佳答案

我认为在层次 View Controller 的另一个窗口中显示插页式广告不是一个好的做法,我们不能说这是错误的。来自苹果文档,

The UIWindow class defines an object known as a window that manages and >coordinates the views an app displays on a device screen. Unless an app can display content on an external device screen, an app has only one window. https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWindow_Class/

关于ios - 插页式实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31852005/

相关文章:

android - 在多个 Activity 中使用相同加载的 AdMob

ios - 从 WebView 中 react native 深度链接

ios - 我应该在类之间共享 UIAlertView 吗?

android - iOS/Android SDK 中的 C++17 支持

iphone - Zbar SDK 和 ios7/xcode 5 - 应用程序的 CPU 使用率达到 100%,内存超过 100MB

ios - build设置中的 "Objective-C Bridging Header"条目未出现在 Xcode 8.3 中

Swift - 从 GADBannerView 扩展后出现无法识别的选择器错误

Android 依赖项 'com.android.support:support-v4' 对于编译 (26.1.0) 和运行时 (27.1.1) 类路径错误有不同的版本

ios - 异步 NSURLConnection 在每个字节之间接收空字节

ios - 如何从 ios 应用程序上传视频到 YouTube?通过使用 Oauth2 和 YouTube DATA 类