【问题标题】:Presenting interstitial ad in fullscreen in iOS 13 Xcode 11在 iOS 13 Xcode 11 中全屏显示插页式广告
【发布时间】:2019-10-10 09:53:02
【问题描述】:

我刚刚将我的 Xcode 更新到 11,并尝试在 iOS 13 设备上运行我的应用程序。我发现视图控制器没有全屏显示,但我可以通过这个问题解决这个问题:Presenting modal in iOS 13 fullscreen

但我也有一个问题,即 Admob 插页式广告没有全屏显示。我会附上截图来演示,你会看到顶部不在顶部。

这就是我展示插页式广告的方式:

if (self.interstitial.isReady) {

    [self.interstitial presentFromRootViewController:self];

}

【问题讨论】:

  • 您是否有机会找到解决方案?
  • @VadimF。不,我的应用仍然如此,我尝试更新 Google Mobile Ads SDK 几次,也是最近,但仍然没有运气...

标签: ios objective-c xcode admob interstitial


【解决方案1】:

这是插页式广告的基本帮助类,它不依赖于我的任何视图或模式实现。它只会在 rootViewController 上显示广告,即使在横向模式下它也可以为我工作,这也可以用于 SwiftUI。如果你还没有,试试这个。

import Foundation
import GoogleMobileAds
import UIKit
    
final class InterstitialAd : NSObject, GADInterstitialDelegate {
    var interstitial: GADInterstitial? = nil
    
    func LoadInterstitial() {
        interstitial = GADInterstitial(adUnitID: Constants.interstitialAdCode)
        let req = GADRequest()
        interstitial!.load(req)
        interstitial!.delegate = self
    }
    
    func showAd() {
        if let ad = self.interstitial, ad.isReady {
           let root = UIApplication.shared.windows.first?.rootViewController
           ad.present(fromRootViewController: root!)
        }
    }
}

【讨论】:

    【解决方案2】:

    将演示模式更改为:

    对不起,我是用 Swift 写的,虽然这在 Objective-C 中应该是类似的。

    viewController.modalPresentationStyle = .fullScreen
    

    或

    viewController.modalPresentationStyle = .overFullScreen
    

    在 iOS 13 上,我注意到默认的 modalPresentationStyle 是 .overCurrentContext 或 .currentContext,这会产生奇怪的动画并最小化呈现的视图控制器的框架。

    【讨论】:

    • 但我不是在展示 View Controller,只是一个插页式广告。
    • 但是广告以某种方式呈现,对吧?它是添加到您当前视图的 UIView 吗?它是一个视图控制器?
    【解决方案3】:

    我认为有一个简单的解决方案,您需要更新 Google Mobile Ads SDK(pod 更新或 carthage 更新)。 广告 SDK:7.50.0,正式发布,支持 iOS 13。

    【讨论】:

      猜你喜欢
      • 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
      相关资源
      最近更新 更多