Ios 将Admob横幅广告移动到嵌入导航控制器(Swift 3)的tableView底部
我无法将横幅广告移动到嵌入导航控制器的tableView底部。当我启动应用程序时,没有显示任何内容,委托方法告诉我广告加载正确。因此,在我看来,问题在于当我设置Ios 将Admob横幅广告移动到嵌入导航控制器(Swift 3)的tableView底部,ios,swift,admob,Ios,Swift,Admob,我无法将横幅广告移动到嵌入导航控制器的tableView底部。当我启动应用程序时,没有显示任何内容,委托方法告诉我广告加载正确。因此,在我看来,问题在于当我设置bannerView.frame时,值UIScreen.main.bounds.height-UIApplication.shared.statusBarFrame.height对于我的屏幕来说太大了。这是我的密码 override func viewDidLoad() { super.viewDidLoad() //
bannerView.frame
时,值UIScreen.main.bounds.height-UIApplication.shared.statusBarFrame.height对于我的屏幕来说太大了。这是我的密码
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)
还有我的
非常感谢。好的,我解决了自己的问题;我想我应该把它贴出来让别人看。我通过导航栏、状态栏和横幅高度偏移了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)
谢谢您的帮助。尝试这种方法UIScreen.main.bounds.height-44
无效。我更新了问题的更多细节。发布您的代码而不是图像我无法嵌入图像,因为没有足够的代表。但我将发布代码。