HeWhoRemains
HeWhoRemains

Reputation: 41

Google AdMob Banner Ad Adds Extra Left Padding in Container View (iOS)

I am integrating a Google AdMob banner ad into a UIView container that has the following constraints:

View Hierarchy

Main View (root view of UIViewController). Container View (inside Main View, used to hold adBannerView). adBannerView (added programmatically inside Container View).

UIViewController's Main View │ ├── Container View (UIView) │ ├── Ad Banner View (GADBannerView or other ad view)

Constraints Container View: Left: 0 (Aligns to the left of the main view) Right: 0 (Aligns to the right of the main view) Bottom: 0 (Sticks to the bottom of the main view) Height: 70 (Fixed height)

Ad Banner View: Same bounds as Container View (matches its frame)

Here is my code for adding the banner ad:

func showAd(bannerViewContainer: UIView, VC: UIViewController) {
    var bannerView: BannerView!
    bannerView = BannerView(adSize: AdSizeFullBanner)
    bannerView.adUnitID = bannerAdsId
    bannerView.rootViewController = VC
    
    bannerView.load(Request())
    bannerView.frame = bannerViewContainer.bounds
    bannerViewContainer.addSubview(bannerView)
}

However, when the ad appears on the screen, I notice that there is extra space on the left side of the banner. The banner is not aligned properly within the container view.

What I Have Tried:

Questions:

Image of output The output I have

Upvotes: 0

Views: 29

Answers (0)

Related Questions