AdMob GADBannerView delay when presenting new VC
Looks like you're trying to create one GADBannerView
to use across your entire application, which is a good idea. You're not doing that though because you're creating a new GADBannerView
in your View Controller's requestAds
function: appDelegate.adBannerView = GADBannerView()
. Remove it.
Also, do your request and set your Ad Unit ID in your app delegate and remove it from your requestAds
function. In your View Controller's viewDidLoad
you should only be positioning your GADBannerView
and adding it to the view.
I imagine you would like the banner to fill the width of the screen too so I've changed the frame
property. If you wanted a function for this it would end up similar to:
func addBannerToView() {
appDelegate.adBannerView.adSize = kGADAdSizeBanner
appDelegate.adBannerView.rootViewController = self
appDelegate.adBannerView.frame = CGRect(x: 0.0,
y: view.frame.height - appDelegate.adBannerView.frame.height,
width: view.frame.width,
height: appDelegate.adBannerView.frame.height)
view.addSubview(appDelegate.adBannerView)
}
Add GADBannerView Programmatically
Well I think you have multiple things to consider:
[sender.view addSubview:bannerView]
does not move other views,
instead you are placing the banner view directly on top of the view
hierarchy.Ads are loaded asynchronously, so you should implement the delegate
methods ofGADBannerView
for showing and hiding the ad view.If you really want to move other views around you should use some
kind of container view to include all other content except your
banner. If you receive an ad you can easily move the container view
(or shrink it) and display your banner view on some location in your
main view.
Cheers
Related Topics
Protocol Extension Initializer Forcing to Call Self.Init
Add Datepicker in Uiactionsheet Using Swift
How to Define an Extension to Collectiontype So That Its Methods Are Available to Dictionaries
Build Realm for Swift 3 & Xcode 8
Swiftui Hstack with Equal Height
How to Record My MAC's Internal Sound, Not the Microphone!, Using Avcapturesession
Why It Is Called the Memberwise Initialiser
Closure Use of Non-Escaping Parameter - Swift 3 Issue
Callback Url Not Approved Despite Being Provided Twitter API
iOS 11 PDFkit Not Updating Annotation Position
Why Do We Need to Explicitly Cast the Optional to Any
Generate Avaudiopcmbuffer with Avaudiorecorder
Scaling Down a Text's Font Size to Fit Its Length to Another Text in Swiftui