i am adding GoogleMobileAds
in Swift
project and i have done all the steps successfully which is provided in doc and ads are showing in my app just issue is that when i push to other ViewController than ads banner view still show on top of ViewController i just want ads bannerview to main screen of tabbar not detail here is my code
var bannerView: GADBannerView!
bannerView = GADBannerView(adSize: kGADAdSizeBanner)
addBannerViewToView(bannerView)
bannerView.adUnitID = "here i add my adUnitID"
bannerView.rootViewController = self
bannerView.load(GADRequest())
func addBannerViewToView(_ bannerView: GADBannerView){
bannerView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(bannerView)
view.addConstraints([
NSLayoutConstraint(item: bannerView,
attribute: .bottom,
relatedBy: .equal,
toItem: tabBar,
attribute: .top,
multiplier: 1,
constant: 0),
NSLayoutConstraint(item: bannerView,
attribute: NSLayoutConstraint.Attribute.centerX,
relatedBy: .equal,
toItem: view,
attribute: .centerX,
multiplier: 1,
constant: 0)
])
}
here is with this code ads loaded successfully but when push to new view controller than bannerview shows on that screen can any one have idea about this?