這是我第一次使用iAd並希望在UICollectionView的每5個單元格中顯示它。我有兩個小區的一個正常,一個用於IAD,我已連接代表對IAdCell和裁判ADBannerViewDelegateiAd UICollectionView每5個單元格
在viewDidLoad中()我有self.canDisplayBannerAds =真
在UICollectionView我使用此代碼決定我想要的細胞回
覆蓋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
類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
}
}
但似乎不顯示廣告是空
感謝 本尼