GoogleInteractiveMediaAds Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
IMAAdDisplayContainer
@interface IMAAdDisplayContainer : NSObject
The IMAAdDisplayContainer is responsible for managing the ad container view and companion ad
slots used for ad playback.
-
View containing the video display and ad related UI. This view must be present in the view
hierarchy in order to make ad or stream requests.
Declaration
Swift
var adContainer: UIView { get }
Objective-C
@property (nonatomic, readonly) UIView *_Nonnull adContainer;
-
View controller containing the ad container. Used to present ad UI in child view controllers. It
must be non-nil in order to make ad or stream requests, and it must be in the view hierarchy
before ad playback.
Declaration
Swift
weak var adContainerViewController: UIViewController? { get set }
Objective-C
@property (nonatomic, weak, nullable) UIViewController *adContainerViewController;
-
The environment to focus on during an ad break. Nil if there is not currently an ad break.
Declaration
Swift
var focusEnvironment: (any UIFocusEnvironment)? { get }
Objective-C
@property (nonatomic, readonly, nullable) id<UIFocusEnvironment> focusEnvironment;
-
List of companion ad slots. Can be nil or empty.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSArray<IMACompanionAdSlot *> *companionSlots;
-
Initializes IMAAdDisplayContainer for rendering the ad and displaying the ad UI without any
companion slots.
Declaration
Swift
init(adContainer: UIView, viewController adContainerViewController: UIViewController?)
Objective-C
- (nonnull instancetype)initWithAdContainer:(nonnull UIView *)adContainer
viewController:(nullable UIViewController *)
adContainerViewController;
Parameters
adContainer
|
The view where the ad will be rendered. Fills the view’s bounds.
|
adContainerViewController
|
The view controller containing the ad container. If not provided
here, must be set on the property before making an ads or stream request.
|
Return Value
A new IMAAdDisplayContainer instance
-
Initializes IMAAdDisplayContainer for rendering the ad and displaying the ad UI.
Declaration
Swift
init(adContainer: UIView, viewController adContainerViewController: UIViewController?, companionSlots: [IMACompanionAdSlot]?)
Objective-C
- (nonnull instancetype)
initWithAdContainer:(nonnull UIView *)adContainer
viewController:(nullable UIViewController *)adContainerViewController
companionSlots:
(nullable NSArray<IMACompanionAdSlot *> *)companionSlots;
Parameters
adContainer
|
The view where the ad will be rendered. Fills the view’s bounds.
|
adContainerViewController
|
The view controller containing the ad container. If not provided
here, must be set on the property before making an ads or stream request.
|
companionSlots
|
The array of IMACompanionAdSlots. Can be nil or empty.
|
Return Value
A new IMAAdDisplayContainer instance
-
Registers a view that overlays or obstructs this container as “friendly” for viewability
measurement purposes.
See Open Measurement
in the IMA SDK for guidance on what is and what is not allowed to be registered.
Parameters
friendlyObstruction
|
An obstruction to be marked as “friendly” until unregistered.
|
-
Unregisters all previously registered friendly obstructions.
Declaration
Swift
func unregisterAllFriendlyObstructions()
Objective-C
- (void)unregisterAllFriendlyObstructions;
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[null,null,["Last updated 2025-08-20 UTC."],[[["\u003cp\u003e\u003ccode\u003eIMAAdDisplayContainer\u003c/code\u003e manages the ad container view and companion ad slots for ad playback in iOS apps.\u003c/p\u003e\n"],["\u003cp\u003eIt requires an \u003ccode\u003eadContainer\u003c/code\u003e (UIView) for rendering the ad and an optional \u003ccode\u003eadContainerViewController\u003c/code\u003e (UIViewController) for presenting ad UI.\u003c/p\u003e\n"],["\u003cp\u003eCompanion ad slots can be provided during initialization or later using the \u003ccode\u003ecompanionSlots\u003c/code\u003e property.\u003c/p\u003e\n"],["\u003cp\u003eFriendly obstructions, such as controls overlaid on the ad, can be registered to improve viewability measurement.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers must ensure the \u003ccode\u003eadContainer\u003c/code\u003e and \u003ccode\u003eadContainerViewController\u003c/code\u003e are in the view hierarchy before making ad requests.\u003c/p\u003e\n"]]],[],null,["# GoogleInteractiveMediaAds Framework Reference\n\nIMAAdDisplayContainer\n=====================\n\n @interface IMAAdDisplayContainer : NSObject\n\nThe IMAAdDisplayContainer is responsible for managing the ad container view and companion ad\nslots used for ad playback.\n- `\n ``\n ``\n `\n\n ### [adContainer](#/c:objc(cs)IMAAdDisplayContainer(py)adContainer)\n\n `\n ` \n View containing the video display and ad related UI. This view must be present in the view\n hierarchy in order to make ad or stream requests. \n\n #### Declaration\n\n Swift \n\n var adContainer: UIView { get }\n\n Objective-C \n\n @property (nonatomic, readonly) UIView *_Nonnull adContainer;\n\n- `\n ``\n ``\n `\n\n ### [adContainerViewController](#/c:objc(cs)IMAAdDisplayContainer(py)adContainerViewController)\n\n `\n ` \n View controller containing the ad container. Used to present ad UI in child view controllers. It\n must be non-nil in order to make ad or stream requests, and it must be in the view hierarchy\n before ad playback. \n\n #### Declaration\n\n Swift \n\n weak var adContainerViewController: UIViewController? { get set }\n\n Objective-C \n\n @property (nonatomic, weak, nullable) UIViewController *adContainerViewController;\n\n- `\n ``\n ``\n `\n\n ### [focusEnvironment](#/c:objc(cs)IMAAdDisplayContainer(py)focusEnvironment)\n\n `\n ` \n The environment to focus on during an ad break. Nil if there is not currently an ad break. \n\n #### Declaration\n\n Swift \n\n var focusEnvironment: (any UIFocusEnvironment)? { get }\n\n Objective-C \n\n @property (nonatomic, readonly, nullable) id\u003cUIFocusEnvironment\u003e focusEnvironment;\n\n- `\n ``\n ``\n `\n\n ### [companionSlots](#/c:objc(cs)IMAAdDisplayContainer(py)companionSlots)\n\n `\n ` \n List of companion ad slots. Can be nil or empty. \n\n #### Declaration\n\n Swift \n\n var companionSlots: [../Classes/IMACompanionAdSlot.html]? { get }\n\n Objective-C \n\n @property (nonatomic, readonly, nullable) NSArray\u003c../Classes/IMACompanionAdSlot.html *\u003e *companionSlots;\n\n- `\n ``\n ``\n `\n\n ### [-initWithAdContainer:viewController:](#/c:objc(cs)IMAAdDisplayContainer(im)initWithAdContainer:viewController:)\n\n `\n ` \n Initializes IMAAdDisplayContainer for rendering the ad and displaying the ad UI without any\n companion slots. \n\n #### Declaration\n\n Swift \n\n init(adContainer: UIView, viewController adContainerViewController: UIViewController?)\n\n Objective-C \n\n - (nonnull instancetype)initWithAdContainer:(nonnull UIView *)adContainer\n viewController:(nullable UIViewController *)\n ../Classes/IMAAdDisplayContainer.html#/c:objc(cs)IMAAdDisplayContainer(py)adContainerViewController;\n\n #### Parameters\n\n |-----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*adContainer*` ` | The view where the ad will be rendered. Fills the view's bounds. |\n | ` `*adContainerViewController*` ` | The view controller containing the ad container. If not provided here, must be set on the property before making an ads or stream request. |\n\n #### Return Value\n\n A new IMAAdDisplayContainer instance\n- `\n ``\n ``\n `\n\n ### [-initWithAdContainer:viewController:companionSlots:](#/c:objc(cs)IMAAdDisplayContainer(im)initWithAdContainer:viewController:companionSlots:)\n\n `\n ` \n Initializes IMAAdDisplayContainer for rendering the ad and displaying the ad UI. \n\n #### Declaration\n\n Swift \n\n init(adContainer: UIView, viewController adContainerViewController: UIViewController?, companionSlots: [../Classes/IMACompanionAdSlot.html]?)\n\n Objective-C \n\n - (nonnull instancetype)\n initWithAdContainer:(nonnull UIView *)adContainer\n viewController:(nullable UIViewController *)adContainerViewController\n companionSlots:\n (nullable NSArray\u003c../Classes/IMACompanionAdSlot.html *\u003e *)companionSlots;\n\n #### Parameters\n\n |-----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*adContainer*` ` | The view where the ad will be rendered. Fills the view's bounds. |\n | ` `*adContainerViewController*` ` | The view controller containing the ad container. If not provided here, must be set on the property before making an ads or stream request. |\n | ` `*companionSlots*` ` | The array of IMACompanionAdSlots. Can be nil or empty. |\n\n #### Return Value\n\n A new IMAAdDisplayContainer instance\n- `\n ``\n ``\n `\n\n ### [-registerFriendlyObstruction:](#/c:objc(cs)IMAAdDisplayContainer(im)registerFriendlyObstruction:)\n\n `\n ` \n Registers a view that overlays or obstructs this container as \"friendly\" for viewability\n measurement purposes.\n\n See [Open Measurement\n in the IMA SDK](https://developers.google.com/interactive-media-ads/docs/sdks/ios/omsdk) for guidance on what is and what is not allowed to be registered. \n\n #### Declaration\n\n Swift \n\n func register(_ friendlyObstruction: ../Classes/IMAFriendlyObstruction.html)\n\n Objective-C \n\n - (void)registerFriendlyObstruction:\n (nonnull ../Classes/IMAFriendlyObstruction.html *)friendlyObstruction;\n\n #### Parameters\n\n |-----------------------------|---------------------------------------------------------------|\n | ` `*friendlyObstruction*` ` | An obstruction to be marked as \"friendly\" until unregistered. |\n\n- `\n ``\n ``\n `\n\n ### [-unregisterAllFriendlyObstructions](#/c:objc(cs)IMAAdDisplayContainer(im)unregisterAllFriendlyObstructions)\n\n `\n ` \n Unregisters all previously registered friendly obstructions. \n\n #### Declaration\n\n Swift \n\n func unregisterAllFriendlyObstructions()\n\n Objective-C \n\n - (void)unregisterAllFriendlyObstructions;"]]