Reputation: 41
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:
bannerView.frame = bannerViewContainer.bounds
, but the issue persists.AdSizeBanner
and AdSizeSmartBannerPortrait
, but the issue remains.Questions:
Upvotes: 0
Views: 29