1
我正在開發一款應用程序,並希望包含iAd's。我已經設法添加橫幅廣告,他們工作得很好。不過,我想要一個更大的添加,填充大部分屏幕,但不是全屏。我從Benzene's Question and given solution from erdekhayser.iAd在SpriteKit中使用Swift
Apple iAd Documentation (Page 3)
我上面已引用是從蘋果文檔和蘋果指在IAD作爲MREC廣告的鏈接添加使用代碼的adBanner。這是我想要的。我無法解決如何創建和添加一個。我嘗試調整adBanner的大小,但仍然無法弄清楚。
任何幫助,將不勝感激
這是我的代碼至今:
import UIKit
import SpriteKit
import iAd
import Twitter
var adBannerView: ADBannerView!
class GameViewController: UIViewController, ADBannerViewDelegate {
var scene: GameScene!
func loadAds() {
adBannerView = ADBannerView(frame: CGRectZero)
adBannerView.delegate = self
adBannerView.hidden = true
view.addSubview(adBannerView)
}
override func viewDidLoad() {
super.viewDidLoad()
// Configure the view.
let skView = view as SKView
skView.showsFPS = false
skView.showsNodeCount = true
skView.showsPhysics = false
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = true
/* Set the scale mode to scale to fit the window */
scene = GameScene(size: skView.bounds.size)
scene.scaleMode = .AspectFill
skView.presentScene(scene)
//iAd
loadAds()
}
//iAd
func bannerViewWillLoadAd(banner: ADBannerView!) {
println("Ad about to load")
}
func bannerViewDidLoadAd(banner: ADBannerView!) {
adBannerView.center = CGPoint(x: adBannerView.center.x, y: view.bounds.size.height - view.bounds.size.height + adBannerView.frame.size.height/2)
adBannerView.hidden = false
println("Displaying the Ad")
}
func bannerViewActionDidFinish(banner: ADBannerView!) {
println("Close the Ad")
}
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
//pause game here
println("Leave the application to the Ad")
return true
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
//move off bounds when add didnt load
adBannerView.center = CGPoint(x: adBannerView.center.x, y: view.bounds.size.height + view.bounds.size.height)
println("Ad is not available")
}
請告訴我們你有什麼樣的代碼迄今 – 2014-10-19 02:43:15
添加的代碼,我有這麼遠。希望你能幫到 – PoisonedApps 2014-10-20 05:36:19
你有沒有遇到過這種情況? – TerranceW 2015-06-18 20:30:13