我试图用AdMob在我的SpriteKit游戏中实现横幅。就像下面的代码所示,我在GameViewController.swift中添加了横幅,但是横幅没有显示在模拟器中。
我想念什么?我正在使用Swift4。
class GameViewController: UIViewController {
var banner:GADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
if let view = self.view as! SKView? {
// Load the SKScene from 'GameScene.sks'
if let scene = SKScene(fileNamed: "GameScene") {
// Set the scale mode to scale to fit the window
scene.scaleMode = .aspectFill
// Present the scene
view.presentScene(scene)
}
view.ignoresSiblingOrder = true
view.showsFPS = true
view.showsNodeCount = true
banner = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
banner.adUnitID = "here is my unit ID -> copy paste so cant be wrong"
banner.rootViewController = self
let req:GADRequest = GADRequest()
banner.load(req)
banner.frame = CGRect(x: 0, y: view.bounds.height - banner.frame.size.height, width: banner.frame.size.width, height: banner.frame.size.height)
view.addSubview(banner)
}
}
答案 0 :(得分:0)
我认为您忘记了声明您的ViewController,因为它符合GADBannerViewDelegate
class GameViewController: UIViewController, GADBannerViewDelegate {
您可以在遵守协议后重试吗?