I'm displaying GADBannerView in my app.
lazy var bannerView: GADBannerView = {
let b = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
b.adUnitID = "... id ..."
b.rootViewController = self
b.load(GADRequest())
return b
}()
It works ok if I display it as a subview of 'self.view'.
self.view.addSubview(contentView)
self.view.addSubview(bannerView)
// autolayout for contentView and bannerView ...
good display ...
But as some requirement, I want to display it inside a vertical UIStackView.
let stack = UIStackView(arrangedSubviews: [contentView, bannerView])
stack.axis = .vertical
stack.distribution = .equalSpacing
stack.alignment = .fill
// autolayout for stack view ...
The problem appears that the ad showing not full width with 2 black ends (left and right) as the image below
bad display ...
I tried Debug View Hierarchy of the GADBannerView and it's all subviews. All seem ok, full size, equal to outer view, 375 as I tested with iPhone 12 mini, as image below
I cannot figure out the problem. If you know this, please help me. Thank you!
question from:
https://stackoverflow.com/questions/65878652/gadbannerview-ad-not-full-width-while-displaying-inside-uistackview 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…