我正在尝试使用以下代码将iAd添加到我的应用中:
var bannerView: ADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
bannerView = ADBannerView(adType: .Banner)
bannerView.translatesAutoresizingMaskIntoConstraints = false
bannerView.delegate = self
bannerView.hidden = true
bannerView.frame = CGRectMake(0, 400, view.frame.size.width, bannerView.frame.size.height)
view.addSubview(bannerView)
即使使用frame = CGRectMake
内容,我的横幅也位于我应用的底部...无论我如何更改x / y值。横幅停留在底部...我错过了什么?非常感谢帮助。
答案 0 :(得分:1)
请试试这个: -
var bannerView: ADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
bannerView =ADBannerView(adType:.Banner)
bannerView.translatesAutoresizingMaskIntoConstraints = false
bannerView.delegate = self
bannerView.hidden = true
bannerView.frame = CGRectMake(0,self.view.frame.size.height-bannerView.frame.size.height,view.frame.size.width,bannerView.frame.size.height)
view.addSubview(bannerView)
}
答案 1 :(得分:1)
尝试按照:
var adBannerView: ADBannerView
adBannerView = ADBannerView(frame: CGRectMake(0, 0, 50, screenBounds.width))
adBannerView.center = CGPoint(x: screenBounds.width/2, y: screenBounds.height-adBannerView.frame.height)
adBannerView.delegate = self
adBannerView.hidden = true
view.addSubview(adBannerView)