簡體   English   中英

iAds Swift app的干擾功能

[英]iAds interfering functionality of Swift app

由於我在我的瑣事應用程序中啟用了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


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

來自canDisplayBannerAds文檔

也可以看看

originalContentView

originalContentView說:

當視圖控制器啟用橫幅廣告時,系統會將視圖控制器的內容視圖置於系統管理的新內容視圖中。 這允許系統在顯示橫幅廣告時動態調整原始內容視圖的大小,以及管理橫幅廣告本身的顯示。 此屬性提供對原始內容視圖的訪問,而不是管理橫幅廣告顯示的包含視圖。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM