Displaying a Player - UIKit

Preparing the UI placement(s) of your player tag(s)

A player tag may be displayed only in one placement view. Displaying the same tag in multiple placement views is not supported and may lead to unexpected behavior.

Use your dashboard to configure the content, visualization and behavior of the player.

To display a player create an AdPlayerPlacementView with one of the previously initialized tag IDs, add it to your layout. Once the player tag is initialized and the AdPlayerPlacementView is visible on the screen, the player will be loaded and the content of the assigned player tag will be presented.

// ViewController.viewDidLoad let placement = AdPlayerPlacementView(tagId: tagId) placement.translatesAutoresizingMaskIntoConstraints = false view.addSubview(placement) NSLayoutConstraint.activate([ placement.leadingAnchor.constraint(equalTo: view.leadingAnchor), placement.trailingAnchor.constraint(equalTo: view.trailingAnchor), placement.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor) ])



Placement Sizing

By default, the SDK will set the placement’s height for you.
To override this behavior - implement AdPlacementLayoutDelegate and set it to `placement.layoutDelegate`

// ViewController.viewDidLoad placement.layoutDelegate = self self.adPlacementHeightConstraint = placement.heightAnchor.constraint(equalToConstant: 0) extension ViewController: AdPlacementLayoutDelegate { func adPlacementHeightWillChange(to newValue: CGFloat) { guard newValue != adPlacementHeightConstraint.constant else { return } adPlacementHeightConstraint.constant = newValue } }


For an advanced UI layout example please refer to the following:
CollectionView Example -> AdPlacementCollectionViewCell
SwiftUI Example