简体   繁体   中英

How to remove ADBannerView in Swift

I am creating a SpriteKit game with multiple scenes. I want to remove the ad once the users starts to play the actual game, then create another ad when the user transitions to the Gameover scene. Hiding the adbannerview does not work, as it will not reappear once the user loses again.

So how do you remove an AdBannerView?

Try to use a NSNotification in the GameViewController, something like this:

    func hideAdBanner(notification: NSNotification) {
    println("hiding banner")
    adBanner.alpha = 0
    adBanner.hidden = true
}


    override func viewDidLoad() {
    super.viewDidLoad()
    NSNotificationCenter.defaultCenter().addObserver(self, selector: "hideAdBanner:" , name: "hideAdBanner", object: nil)
    }

Then call this NSNotification in your scene

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM