Integrating Inline Ads in UITableView - adform/adform-ios-sdk GitHub Wiki
Adding ads to UITableView
Inline ads can be added to a UITableView
or any other collection view container. It can be added as a UITableView
section headers and footers or cells. When adding ad view to table view you should ensure that you are properly reusing views to avoid performance issues. The example code provided below shows you how to add inline ads to table view as section footers.
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return AFAdInline.defaultAdSize().height
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if let footer = tableView.dequeueReusableHeaderFooterView(withIdentifier: "AdFooterIdentifier") {
return footer
}
let footer = UITableViewHeaderFooterView(reuseIdentifier: "AdFooterIdentifier")
let adView = AFAdInline(adTag: masterTag, presenting: self)
footer.addSubview(adView)
adView.loadAd()
return footer
}
Sample code:
For a complete example of how to add Adform inline ads to UITableView
, check out the sample app.