InMobi / sdk-sample-code-ios

This repository contains InMobi iOS SDK sample code for different ad-formats, which publishers can use to incorporate in their apps
MIT License
18 stars 12 forks source link

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

Open jaisan123 opened 6 years ago

jaisan123 commented 6 years ago

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.