这是我第一次使用iAd并希望在UICollectionView中的每5个单元格上显示它 . 我有两个单元格正常,一个用于iAd,我已将委托连接到IAdCell并参考ADBannerViewDelegate
在viewDidLoad()中,我有self.canDisplayBannerAds = true
在UICollectionView中,我使用此代码来决定我想要返回的单元格
override func collectionView(collectionView:UICollectionView,cellForItemAtIndexPath indexPath:NSIndexPath) - > UICollectionViewCell {
let isBanner = movies[indexPath.row].TmdbId == nil
if(isBanner){
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("iAdCell", forIndexPath: indexPath) as! IAdCell
return cell
}
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! LatestMovieTVCell
return cell
}
细胞看起来像这样
导入UIKit导入iAd
class IAdCell:UICollectionViewCell,ADBannerViewDelegate {
@IBOutlet var IAdBanner: ADBannerView!
override func awakeFromNib() {
super.awakeFromNib()
IAdBanner.hidden = true
}
func bannerViewDidLoadAd(banner: ADBannerView!) {
banner.hidden = false
}
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
return true
}
}
但似乎没有显示广告是空的
谢谢Bennie
1 回答
Apple关闭了iAd网络:
https://developer.apple.com/support/iad/
所有
iAd.framework
内容都已弃用 . 那个's why you'没有看到任何东西 .