Design issue with MoPub Native Ads on iOS UITableView



Please see the screenshot below.

The MoPub native ad cell for some reason has a tableview separator in the middle of it. I don’t think this is a problem on my end. The top separator you see is showing normal behavior. There should be a separator below the ad cell, but it appears to have moved up into the middle of the ad and I can’t get rid of it.

If anyone knows a way I can fix this (preferably without removing all separators from my table view) please let me know.

Swift 1.2
iOS 8.4


Hello Campus_files,

Can you include the code snippet for how you implemented your native ad cell, so we can help troubleshoot?



Sure thing.

First of all, the native ad cell is not connected to Storyboard in any way.

Class definition:

class NativeAdCell: UITableViewCell, MPNativeAdRendering

Ad outlets:

var mainTextLabel = UILabel()
var titleLabel = UILabel()
var iconImageView = UIImageView()
var mainImageView = UIImageView()

I later set frames and appearances for these outlets in override func layoutSubviews(), and add them to the contentView.

I set the cell height:

static func sizeWithMaximumWidth(maximumWidth: CGFloat) -> CGSize {
    let screenSize: CGRect = UIScreen.mainScreen().bounds
    let adCellWidth = screenSize.width
   //... I do some math to get a cellHeight ...
    return CGSize(width: maximumWidth, height: cellHeight)

I layout ad assets:

func layoutAdAssets(adObject: MPNativeAd!) {

Then I call upon the cell in my tableViewController with this:
placer = MPTableViewAdPlacer(tableView: tableView, viewController: self, defaultAdRenderingClass: NativeAdCell.self)

Hope this gives a good picture. In the meantime, I went ahead and did tableView.separatorColor = UIColor.clearColor() to hide the separators, which does not look as bad in my design as I thought it would, so the problem isn’t a detrimental one.