gpt4 book ai didi

ios - iAds 干扰 Swift 应用程序的功能

转载 作者:搜寻专家 更新时间:2023-10-31 23:02:01 24 4
gpt4 key购买 nike

自从我在我的问答应用程序中启用了 iAds 后,每次加载新问题时本应更改的背景不再更改。当我注释掉 canDisplayBannerAds 行时,它再次起作用。关于什么可能是错误的任何想法?

import UIKit
import iAd

class ViewController: UIViewController {

@IBOutlet weak var funFactLabel: UILabel!

@IBOutlet weak var funFactButton: UIButton!
let factBook = FactBook()
let colorWheel = ColorWheel()

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
funFactLabel.text = factBook.randomFact()
self.canDisplayBannerAds = true
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

@IBAction func showFunFact() {
let randomColor = colorWheel.randomColor()
view.backgroundColor = randomColor
funFactButton.tintColor = randomColor
funFactLabel.text = factBook.randomFact()
}

}

最佳答案

与其使用 view.backgroundColor = randomColor,不如使用 originalContentView.backgroundColor = randomColor


我是如何得到解决方案的:

来自documentation for canDisplayBannerAds

See Also

originalContentView

originalContentView说:

When a view controller enables banner ads, the system puts the view controller’s content view inside of a new content view that the system manages. This allows the system to dynamically resize the original content view when a banner ad is displayed, as well as managing the display of the banner ad itself. This property provides access to the original content view, rather than the containing view that manages banner ad display.

关于ios - iAds 干扰 Swift 应用程序的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32556331/

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