我的应用程序Dotcha!现在在应用程序商店,我正在尝试在xcode中进行更新。在我的更新中,我修复了一些小问题和一些重要的事情。我的问题是我搞砸了我工作的插页式广告,现在他们似乎不再工作了。这是我的代码。
func Close(sender:UIButton){
closeButton.removeFromSuperview()
InterAdView.removeFromSuperview()
}
func loadAd() {
println("load ad")
InterAd = ADInterstitialAd()
InterAd.delegate = self
}
func interstitiallAdDidLoad(interstitialAd: ADInterstitialAd!) {
println("ad did load")
InterAdView = UIView()
InterAdView.frame = self.view.bounds
view.addSubview(InterAdView)
InterAd.presentInView(InterAdView)
UIViewController.prepareInterstitialAds()
InterAdView.addSubview(closeButton)
}
func interstitialAdDidUnload(interstitialAd: ADInterstitialAd!) {
println("Ad Unloaded")
InterAdView.removeFromSuperview()
closeButton.removeFromSuperview()
}
func interstitialAd(interstitialAd: ADInterstitialAd!, didFailWithError error: NSError!) {
println("failed to receive")
println(error.localizedDescription)
closeButton.removeFromSuperview()
InterAdView.removeFromSuperview()
}
func RandomInterstitialAd(){
var RandomAd = arc4random() % 6
switch(RandomAd){
case 0:
break
case 1:
loadAd()
break
case 2:
break
case 3:
loadAd()
break
case 4:
break
case 5:
break
default:
break
}
在viewDidLoad中关闭按钮代码:
closeButton.frame = CGRectMake(20, 20, 30, 30)
closeButton.layer.cornerRadius = 10
closeButton.setTitle("X", forState: .Normal)
closeButton.setTitleColor(UIColor.blackColor(), forState: .Normal)
closeButton.backgroundColor = UIColor.whiteColor()
closeButton.layer.borderColor = UIColor.blackColor().CGColor
closeButton.layer.borderWidth = 1
closeButton.addTarget(self, action: "Close:", forControlEvents: UIControlEvents.TouchDown)
}
var InterAd = ADInterstitialAd()
var InterAdView: UIView = UIView()
var closeButton = UIButton.buttonWithType(UIButtonType.System) as! UIButton
按下a按钮时调用RandomInterstitialAd()函数。控制台在加载广告中打印,但广告从不加载。请帮忙。