Skip to main content

Banner Placement

Banner placements display an anchored adaptive ad pinned to a fixed slot in your view hierarchy. The banner auto-resizes as the ad renders — pin it with Auto Layout (centre + bottom shown below) instead of a fixed-height frame so the JS engine can drive its own height.


Sample App

The official Teads SDK sample application includes working examples of this format. Use it for implementation examples and as a reference while you set up this placement.

Teads iOS Sample App on GitHub

Example​

import UIKit
import TeadsSDK

final class BannerViewController: UIViewController, TeadsAdPlacementEventsDelegate {

private var banner: TeadsAdPlacementBanner?

override func viewDidLoad() {
super.viewDidLoad()

// 1. Build the placement configuration
let config = TeadsAdPlacementBannerConfig(
articleUrl: URL(string: "https://yoursite.com/article")!,
widgetId: "MB_10", // Provided by your Teads account manager
installationKey: "YOUR_INSTALLATION_KEY"
)

// 2. Create the placement and load the ad
let placement = TeadsAdPlacementBanner(config, delegate: self)
banner = placement

do {
let adView = try placement.loadAd()

// 3. Pin it to your view hierarchy (do not use a fixed-height frame).
adView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(adView)
NSLayoutConstraint.activate([
adView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
adView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
adView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
} catch {
print("Failed to load banner: \(error)")
}
}

// MARK: - TeadsAdPlacementEventsDelegate

func adPlacement(
_ placement: TeadsAdPlacementIdentifiable?,
didEmitEvent event: TeadsAdPlacementEventName,
data: [String: Any]?
) {
// React to placement lifecycle events — see Placement Events Listener for the full event reference.
}
}

Best Practices​

Dynamic height

The banner drives its own height from the JS engine. Don't constrain it to a fixed height — that will clip the creative as it resizes.

Do not open the click URL

The SDK opens the paid clicked URL. Do not navigate in that handler or the browser will open twice. Use it for tracking only. clickedOrganic, if the placement supports it, is publisher-owned — you still open that URL yourself.

Ad Lifecycle Listener​

Implement TeadsAdPlacementEventsDelegate to observe playback, clicks, and viewability. See Placement Events Listener for the full event reference and error handling guide.

Checklist​