我无法将横幅广告移动到嵌入导航控制器的tableView底部。当我启动应用程序时,没有显示任何内容,并且委托方法告诉我该广告已正确加载。因此,在我看来,问题是当我设置UIScreen.main.bounds.height - UIApplication.shared.statusBarFrame.height
时,值bannerView.frame
对于我的屏幕来说太大了。这是我的代码
override func viewDidLoad() {
super.viewDidLoad()
//Ad display
let naviLen = UIApplication.shared.statusBarFrame.height
bannerView = GADBannerView(adSize: kGADAdSizeFullBanner)
print(UIScreen.main.bounds.height)
bannerView.frame = CGRect(x: 0.0,
y: UIScreen.main.bounds.height - naviLen,
width: bannerView.frame.width,
height: bannerView.frame.height)
bannerView.delegate = self
self.view.addSubview(bannerView)
bannerView.adUnitID = Passwords.adMobAdID
bannerView.rootViewController = self
let request = GADRequest()
request.testDevices = [ kGADSimulatorID] // All simulators
bannerView.load(request)
还有我的output
非常感谢。
答案 0 :(得分:1)
好的,我解决了自己的问题;我想我应该发布给其他人看。我将y坐标偏移了导航栏的高度,状态栏和横幅高度:
bannerView = GADBannerView(adSize: kGADAdSizeFullBanner)
let offset = UIApplication.shared.statusBarFrame.height + (self.navigationController?.navigationBar.bounds.height)! + bannerView.frame.height
print(UIScreen.main.bounds.height)
bannerView.frame = CGRect(x: 0.0,
y: UIScreen.main.bounds.height - offset ,
width: bannerView.frame.width,
height: bannerView.frame.height)
感谢您的帮助。