因此,我在應用程序中實施了iAd,導入了框架並將其導入到View Controller中,並添加了委託和所有內容。當我運行我的應用程序時,我確實看到了它,但是,我有一個標籤欄(如果這很重要,我沒有使用標籤欄控制器),並且我希望在標籤欄上方具有iAd,因爲目前我正在獲取它標籤欄,並覺得這不利於用戶體驗,而蘋果公司的文檔也提到將它直接放在標籤欄上方(https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/iAdRichMediaAds.html)。我一直在玩它,但沒有得到任何工作,並想知道是否有人對我的代碼下面發佈的任何建議。謝謝。在Swift中在標籤欄上方顯示iAd Banner
var bannerView: ADBannerView!
@IBOutlet weak var tabBar: UITabBar!
override func viewDidLoad() {
super.viewDidLoad()
self.canDisplayBannerAds = true
bannerView = ADBannerView(frame: CGRectZero)
bannerView.frame = CGRectMake(0, self.view.frame.size.height - self.tabBar.frame.size.height - bannerView.frame.size.height, self.view.frame.size.width, bannerView.frame.size.height)
bannerView.alpha = 0.0
bannerView.delegate = self
self.view!.addSubview(bannerView)
func bannerViewDidLoadAd(banner: ADBannerView!) {
print("bannerViewDidLoadAd")
bannerView.hidden = false
}
func bannerView(banner: ADBannerView, didFailToReceiveAdWithError error: NSError) {
UIView.animateWithDuration(0.5, animations: {banner.alpha = 1.0})
UIView.commitAnimations()
bannerView.hidden = true
}
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
return true
}
這完全是一種非生產性的答案。我遇到了這個問題,試圖在標籤欄上方放置一個視圖,所以真正的答案*可能會有幫助... – mrwheet