我最近将我的游戏发布到App Store。现在差不多一周后,iAd横幅和中型广告才出现。它的所有显示都是空白区域,如以下屏幕截图所示。
任何人都可以检查我的iAd代码是否有任何问题吗?
import UIKit
import SpriteKit
import iAd
import Social
import GameKit
import StoreKit
class GameViewController: UIViewController, ADBannerViewDelegate, GKGameCenterControllerDelegate, ADInterstitialAdDelegate {
var scene: GameScene!
@IBOutlet var bannerView: ADBannerView!
var imageView = UIImageView()
var interAd = ADInterstitialAd()
var mediumRectAdView = ADBannerView(adType: ADAdType.MediumRectangle)
var interAdView = UIView()
var closeButton = UIButton(type: UIButtonType.System)
override func viewDidLoad() {
super.viewDidLoad()
let screenBounds: CGRect = UIScreen.mainScreen().bounds
bannerView = ADBannerView(frame:CGRectMake(0,0,50,screenBounds.width))
bannerView.center = CGPoint(x: screenBounds.width/2, y:screenBounds.height-bannerView.frame.size.height/2)
bannerView.delegate = self
bannerView.hidden = false//false //<<<<<<<<<<<<<<<<<<<<<<,
scene = GameScene(size:CGSize(width: 2048, height: 1536))
let skView = self.view as! SKView
scene.scaleMode = .AspectFill
skView.presentScene(scene)
skView.addSubview(bannerView)
if scene.productPurchased == true {
bannerView.hidden = true
}
firstScene = false
//self.interstitialPresentationPolicy = ADInterstitialPresentationPolicy.Manual
//Authenticate Game Center
NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(GameViewController.showAuthenticationViewController),name:PresentAuthenticationViewController, object: nil)
SGGameKit.sharedInstance.authenticateLocalPlayer()
// Share
NSNotificationCenter.defaultCenter().addObserver(self, selector: (#selector(GameViewController.displayShareSheet)), name:mySharePostKey, object: nil)
// Med iAD
NSNotificationCenter.defaultCenter().addObserver(self, selector: (#selector(GameViewController.loadMedAd)), name:myloadMedAdKey, object: nil)
// Interstitial iAD
NSNotificationCenter.defaultCenter().addObserver(self, selector: (#selector(GameViewController.loadInterAd)), name:myloadInterAdKey, object: nil)
// Hide Iad
NSNotificationCenter.defaultCenter().addObserver(self, selector: (#selector(GameViewController.hideAd)), name:myHideAdKey, object: nil)
}
func hideAd() {
print("Hiding Ad")
bannerView.hidden = true
}
func displayShareSheet() {
let initialText = "OMG! I got \(scene.score) points in Jumpox\n" + "https://itunes.apple.com/us/app/id1099659993)"
if let myImage = self.view?.pb_takeSnapshot() {
UIImageWriteToSavedPhotosAlbum(myImage, nil, nil, nil)
let activityViewController = UIActivityViewController(activityItems: [initialText,myImage as UIImage], applicationActivities: [])
activityViewController.excludedActivityTypes = [UIActivityTypeOpenInIBooks]
if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Phone {
self.presentViewController(activityViewController, animated: true, completion: {})
}
else {
let popup: UIPopoverController = UIPopoverController(contentViewController:activityViewController)
popup.presentPopoverFromRect(CGRectMake(self.view.frame.size.width / 2, self.view.frame.size.height / 4, 0, 0), inView: self.view, permittedArrowDirections: UIPopoverArrowDirection.Any, animated: true)
}
}
}
func loadMedAd() {
print("Loading loadMedAd")
closeButton = UIButton(type: UIButtonType.System)
closeButton.frame = CGRectMake(5, 5, 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: #selector(GameViewController.close), forControlEvents: UIControlEvents.TouchDown)
mediumRectAdView!.delegate = self
mediumRectAdView.center = self.view.center
mediumRectAdView.addSubview(closeButton)
interAdView = UIView(frame: self.view.frame)
self.view.addSubview(interAdView)
interAdView.addSubview(mediumRectAdView)
}
func loadInterAd() {
print("Loading loadInterAd")
interAd = ADInterstitialAd()
interAd.delegate = self
//if interAd.loaded {
closeButton.frame = CGRectMake(10, 10, 40, 40)
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: #selector(GameViewController.close), forControlEvents: UIControlEvents.TouchDown)
interAdView = UIView(frame: self.view.frame)
interAdView.frame = self.view.bounds
self.view.addSubview(interAdView)
interAd.presentInView(interAdView)
interAdView.addSubview(closeButton)
//}
//requestInterstitialAdPresentation()
}
func interstitialAd(interAd: ADInterstitialAd!, didFailWithError error: NSError!) {
print("Failed To Receive")
closeButton.removeFromSuperview()
interAdView.removeFromSuperview()
}
func close() {
closeButton.removeFromSuperview()
interAdView.removeFromSuperview()
}
func interstitialAdDidUnload(interstitialAd: ADInterstitialAd!) {
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func showAuthenticationViewController() {
let gameKitHelper = SGGameKit.sharedInstance
if let authenticationViewController = gameKitHelper.authenticationViewController {
self.presentViewController(authenticationViewController, animated: true,
completion: nil)
}
}
func gameCenterViewControllerDidFinish(gameCenterViewController: GKGameCenterViewController){
gameCenterViewController.dismissViewControllerAnimated(true, completion: nil)
}
deinit {
NSNotificationCenter.defaultCenter().removeObserver(self)
}
}
答案 0 :(得分:0)
iAd has been discontinued并且不接受新的应用进入网络。
iAd App Network将于2016年6月30日停止营业 我们不再接受新的应用程序进入网络广告 广告系列可能继续投放,您仍然可以获得广告 截至6月30日的收入。如果您想继续推广自己的应用 通过iAd,您可以使用iAd Workbench创建广告系列。
我很惊讶审稿人没有拒绝你的提交。查看AdMob,AppLovin或iOS可用的许多其他广告网络。