-
Notifications
You must be signed in to change notification settings - Fork 8
Integrating Inline Ads in UITableView
Vladas Drejeris edited this page Jun 4, 2021
·
2 revisions
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.
Swift
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
}
Objective-C
- (CGFloat )tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
//Returns default ad view size 320x50 for iPhone and 728x90 for iPad, you should use some kind of constant defining the size of your ad placement.
return [AFAdInline defaultAdSize].height;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UITableViewHeaderFooterView *footerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"AdFooterIdentifier"];
if (!footerView) {
footerView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:@"AdViewFooterIdentifier"];
AFAdInline *adView = [[AFAdInline alloc] initWithMasterTagId:mtag presentingViewController:self];
[footerView.contentView addSubview:adView];
[adView loadAd];
}
return footerView;
}
For a complete example of how to add Adform inline ads to UITableView
, check out the sample app.
Basic integrations
- Integrating Inline Ad
- Integrating Full Screen Overlay Ad
- Integrating AdHesion Ad
- Integrating Interstitial Ad
- Video Ad Integration
- Debug mode
- Troubleshooting
Advanced integrations
- Advanced Inline Ad Integration
- Integrating Inline Ads in UITableView
- Advanced Full Screen Overlay Ad Integration
- Advanced Interstitial Ad Integration
- Instream Video Ads
Other
- Adding Custom Values
- Adding Keywords
- Adding Key Value Pairs
- Adding Search Words
- Location Tracking
- Security
- Ad Tags
- Header Bidding
- Changing ADX Domain
- Specifying banner loading behaviour
- Customizing in app browser
- GDPR
- US Privacy
- Localization
- In app deeplinks
- Native Ads
Mediation adapters