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!) {
adObject.loadIconIntoImageView(self.iconImageView)
adObject.loadTitleIntoLabel(self.titleLabel)
adObject.loadImageIntoImageView(self.mainImageView)
adObject.loadTextIntoLabel(self.mainTextLabel)
}
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.