gpt4 book ai didi

Swift - 从 GADBannerView 扩展后出现无法识别的选择器错误

转载 作者:行者123 更新时间:2023-11-28 07:27:28 25 4
gpt4 key购买 nike

我想构建像其他 View 一样扩展 GADBannerView 的自定义类,但它不起作用

class ListAd:GADBannerView {
var controller: UIViewController?

convenience init(hostView: UIView, controller: UIViewController) {
self.init(frame: hostView.bounds)
self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.translatesAutoresizingMaskIntoConstraints = false
self.controller = controller
hostView.addSubview(self)
}

func loadAd() {
if APP.displayBannerAd {
self.adUnitID = ADMOBIDS["banner"]
self.rootViewController = controller
self.load(GADRequest())
}
}
}

然后我初始化它

admobBanner = ListAd(hostView: self.view, controller: self)
admobBanner?.loadAd()

出现错误:

[App.ListAd setAdUnitID:]:无法识别的选择器发送到实例 0x7fe7f9c04d60'

最佳答案

尝试调用 init(adSize: GADAdSize, origin: CGPoint)init(adSize: GADAdSize) 而不是 self.init(frame:)

关于Swift - 从 GADBannerView 扩展后出现无法识别的选择器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56037578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com