Skip to content

Getting only a gray color in the cell while showing in-feed ad in tableview cell. #14

@jaisan123

Description

@jaisan123

Hi, im integrating in-feed ad in a tableview.I want to show the in-feed ad after every 5 cells. Im calling the ad load method in the cellForRowAtIndexPath .But im getting only a gray color in the table cell.

 let  cell = tableView.dequeueReusableCell(withIdentifier: "adCell", for: indexPath) as! adCell
        self.refreshInMobiStrandAd()
        cell.adDescription.text = adDes
        cell.sponsored.text = adcta
       cell.name.text = adTitle
       cell.icon.image = icon
        cell.mainAd.addSubview(navtive)
        return cell

This is my ad-loading function

func refreshInMobiStrandAd() {
     
         self.InMobiNativeAd?.recyclePrimaryView()
        self.InMobiNativeAd = IMNative(placementId: 1528041596573)
        self.InMobiNativeAd?.delegate = self
        self.InMobiNativeAd?.load()
    }

Im using the delegate method as below

  var navtive = UIView()
    var adcta = ""
    var adDes = ""
    var icon = UIImage()
    var url = ""
    var adTitle = ""

    func nativeDidFinishLoading(_ native: IMNative!) {
   
        adcta = native.adCtaText
        adDes = native.adDescription
        icon = native.adIcon
        adTitle = native.adTitle
        navtive = native.primaryView(ofWidth: UIScreen.main.bounds.width)

       
    }

I'm also recycling the primary view on didEndDisplayingCell like below

 func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {

        if indexPath.row == 2 {

           self.InMobiNativeAd?.recyclePrimaryView()
        }

        else if indexPath.row == 8 {
           self.InMobiNativeAd?.recyclePrimaryView()
        }

    }

Im getting the icon,text and description loading correctly on the tableview.But im getting only a gray color in for the main ad-content which im setting on the UIView navtive variable. Where im making mistake.Please help me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions