开发者

Posts are hiding under the Second Cell In CollectionView

i ma making Swi开发者_如何学Goft app with Xcode and using CollectionViewCell to fetch data from my WordPress Website. i have 2 cells in my CollectionView , one for loading posts and second for Google AdMob , I want to show Ads after 4 posts which is working great but now the problem is when Second cell is loaded i mean AdMob cell loaded then the post of that number is hidden behind it , like if there are posts of number 1,2,3,4,5 and ads load after 4 posts then number 5 post is no where.. this is my code

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    
     if (indexPath.item % 5 == 1){
        
        let adcell = collectionView.dequeueReusableCell(withReuseIdentifier: "adcell", for: indexPath) as! MovieCollectionViewCell
       
       // Google Ads Here
        
       return adcell
        
    }
    
    else{
        
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MovieCollectionViewCell", for: indexPath) as! MovieCollectionViewCell
        
        cell.setup(with: newsData[indexPath.row])
        return cell
    }
}

please help me to solve this , i want to load ads but when ad loaded the post of that number should be loaded in next item cell.. thanks

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜