简体   繁体   English

我的应用程式中的iAd无法运作

[英]iAd in my app doesn't work

I added iAd banner in my app, and the code is like this: 我在应用中添加了iAd横幅,代码如下:

@IBOutlet var adBannerview: ADBannerView?

and codes that in viewDidLoad : 和在viewDidLoad代码:

    self.canDisplayBannerAds = true
    self.adBannerview?.delegate = self
    self.adBannerview?.hidden = true

then: 然后:

 override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
    func bannerViewWillLoadAd(banner: ADBannerView!) {


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


    }
   func bannerViewActionDidFinish(banner: ADBannerView!) {


    }

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

        return true

    }

   func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError: NSError!) {
    self.adBannerview?.hidden = true


    }



}

Now, my app is sale on app store, I downloaded that, but when I open it, found there's no ads on the bottom, is that something wrong with my code? 现在,我的应用程序正在应用程序商店中出售,我下载了它,但是当我打开它时,发现底部没有广告,我的代码有问题吗? But when I run the app on simulator, it says "Connected to iAd". 但是,当我在模拟器上运行该应用时,它显示为“已连接到iAd”。 Appreciate if you help! 感谢您的帮助!

You're actually attempting to implement two iAd ADBannerView 's here. 您实际上是在尝试实现两个iAd ADBannerView You can use either the self.canDisplayBannerAds = true , which you have in your viewDidLoad function, and remove your other iAd code ( @IBOutlet var adBannerview: ADBannerView? , self.adBannerview?.delegate = self , self.adBannerview?.hidden = true ). 您可以使用viewDidLoad函数中具有的self.canDisplayBannerAds = true ,并删除其他iAd代码( @IBOutlet var adBannerview: ADBannerView?self.adBannerview?.delegate = selfself.adBannerview?.hidden = true )。 self.canDisplayBannerAds = true will create an iAd banner for you and manage itself whether it receives an ad from iAd or not. self.canDisplayBannerAds = true将为您创建一个iAd横幅,并自行管理是否从iAd接收广告。 This is the no hassle way of implementing iAd banners into your application but doesn't allow for much control. 这是在您的应用程序中实施iAd标语的简便方法,但是并没有太多的控制权。

Alternatively, you could remove self.canDisplayBannerAds = true and implement the iAd ADBannerView yourself. 或者,您可以删除self.canDisplayBannerAds = true并自己实现iAd ADBannerView This allows for more control but does require more than just one line of code to get it up and running, but it is still very simple to implement. 这样可以进行更多控制,但确实需要多于一行代码来启动和运行它,但是实现起来仍然非常简单。 You can check my answer here for some guidance if you choose to go this route. 如果您选择这条路线,可以在这里查看我的回答以获取一些指导。

Also, you have all of your ADBannerView 's delegate methods inside your view controllers didReceiveMemoryWarning function. 另外,您在视图控制器didReceiveMemoryWarning函数中拥有所有ADBannerView的委托方法。 They need to be placed outside of this and any other function. 它们需要放置在此功能和任何其他功能之外。

It often takes a week or more for live ads to start appearing. 实时广告通常需要一周或更长时间才能开始展示。 There is a separate review process from Apple's ad team that can take up to 10 business days in the worst case. 在最坏的情况下,苹果公司的广告团队有单独的审核流程,该流程最多可能需要10个工作日。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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