So I want to add ads inside my UIcollectionView. After every 4th folder, I want to show an ad (for a total of 3 times,hence the row 4,9 and 14).
I've tried the following:
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if indexPath.row == 4 || indexPath.row == 9 || indexPath.row == 14 {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "AdUnitsCollectionViewCell", for: indexPath) as? AdUnitsCollectionViewCell
//cell?.addSubview(AdUnitController().getBannerView(2))
//cell?.view = AdUnitController().getBannerView(2)
cell?.view.adUnitID = "/6499/example/banner"
cell?.view.rootViewController = self
cell?.view.load(DFPRequest())
return cell!
} else {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FolderViewCellIdentifier, for: indexPath) as? FolderViewCell
cell!.configure(folders![indexPath.row])
return cell!
}
}
This does indeed show the ads 3 times after every 4th folder, but now my folder for that indexPath.row isn't shown anymore (4, 9 and 14). Is there a way I can add my ads inside the collectionview AND my folders as well?
Thanks!