我试图在我的第一个iOS项目中添加Admob横幅。 这是我的代码:
import UIKit
import GoogleMobileAds
class ViewController: UIViewController, WKNavigationDelegate {
@IBOutlet weak var bannerView: GADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
let request = GADRequest()
request.testDevices = [kGADSimulatorID]
bannerView.adUnitID = "ca-app-pub-..." //error
bannerView.rootViewController = self
bannerView.load(request)
}
}
每当我运行应用程序时,我都会:
fatal error: unexpectedly found nil while unwrapping an Optional value
如何解决这个问题?