Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将Admob横幅广告移动到嵌入导航控制器(Swift 3)的tableView底部_Ios_Swift_Admob - Fatal编程技术网

Ios 将Admob横幅广告移动到嵌入导航控制器(Swift 3)的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() //

我无法将横幅广告移动到嵌入导航控制器的tableView底部。当我启动应用程序时,没有显示任何内容,委托方法告诉我广告加载正确。因此,在我看来,问题在于当我设置
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
无效。我更新了问题的更多细节。发布您的代码而不是图像我无法嵌入图像,因为没有足够的代表。但我将发布代码。