iOS SDK Advanced Usage


TableViewAdPlacer is used for displaying dynamic banner ads in UITableViews. Dynamic banner ads have their own predefined positions thus, they will not be loaded until the user scrolls to that specific position.

This comes with a few advantages:

  1. Loading banner ads not at the initial screen load, but rather on user scroll action increases load time performance of your screens.
  2. Loading banner ads only when they will be visible to the user, increases viewability metrics.
  3. Predefined positions can be updated without the need of sending a new app update, which gives the app owners ability to change the banner positions even when the app is live.
  4. As the banners are displayed dynamically, app owners can remove the banners from certain pages without the need of a new app update. Just like changing banner positions, this can also be done while the app is live.

Loading and displaying of banner ads are handled within TableViewAdPlacer which makes integration of banner ads quite easy.


With only a few lines of code you can start using TableViewAdPlacer on your projects. However, there is only one precondition for using it:

  • If you are using UITableView's dequeueReusableCell(withIdentifier identifier: String, for indexPath: IndexPath) then you need to change it to dequeueReusableCell(withIdentifier identifier: String).
  • If you are using editingStyleForRowAt implementation for row edit actions, then you need to change it to editActionsForRowAt.


Step 1: After creating your UITableView and setting its delegate and dataSource properties create a TableViewAdPlacer object.

Step 2: Once the TableViewAdPlacer object is created, set its adCategories and pass your UITableView to the setTableView function.

Step 3: Finally change your myTableView.reloadData() calls with adPlacer.reloadWithAds().

Done: That's it! Now your app is ready to show dynamic banner ads.

Full Example

class MyViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var myTableView: UITableView!
var adPlacer: TableViewAdPlacer!
override func viewDidLoad() {
// Register cells and configure myTableView etc.
// ...
myTableView.dataSource = self
myTableView.delegate = self
adPlacer = TableViewAdPlacer()
adPlacer.adCategories = adCategories
override func viewDidAppear(_ animated: Bool) {
adPlacer.tableViewIsVisible() // Enable auto refresh on loaded banner ads
override func viewDidDisappear(_ animated: Bool) {
adPlacer.tableViewIsInvisible() // Disable auto refresh when user leaves screen
func loadPage() {
// Create your data to be displayed
// ...
adPlacer.reloadWithAds() // myTableView.reloadData()