简体   繁体   中英

How to get iAds advertising in Swift

I have successfully implemented iAds. But they won't display an actual ad. What's wrong with this code?Any help would be greatly appreciated.

I have successfully implemented iAds. But they won't display an actual ad. What's wrong with this code?Any help would be greatly appreciated.

import iAd


class ViewController: UIViewController, MCBrowserViewControllerDelegate, ADBannerViewDelegate {

    @IBOutlet weak var adBannerView: ADBannerView!

override func viewDidLoad() {
        super.viewDidLoad()

        self.canDisplayBannerAds = true
        self.adBannerView?.delegate = self
        self.adBannerView?.hidden = true
}


    func bannerViewWillLoadAd(banner: ADBannerView!) {

    }

    func bannerViewDidLoadAd(banner: ADBannerView!) {
        self.adBannerView?.hidden = false
    }

    func bannerViewActionDidFinish(banner: ADBannerView!) {

    }

    func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {

        return true
    }

    func bannerView(banner: ADBannerView!, didFailtoRecieveAdWithError error: NSError!) {

    }
}

截图

那么在Apple和App Store批准之前,您的应用不会展示任何广告。

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