GoogleInteractiveMediaAds Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
IMACompanionAdSlot
@interface IMACompanionAdSlot : NSObject
Ad slot for companion ads. The SDK will put a subview inside the provided
UIView container. The companion will be matched to the width and height
provided here. This class cannot be instantiated on tvOS, where companion ads
are not available.
-
The view the companion will be rendered in. Display this view in your
application before video ad starts.
Declaration
Swift
var view: UIView { get }
Objective-C
@property (nonatomic, readonly) UIView *_Nonnull view;
-
Width of the slot, in pixels. This value is sent to the DFP ad server for
targeting.
Declaration
Swift
var width: Int { get }
Objective-C
@property (nonatomic, readonly) NSInteger width;
-
Height of the slot, in pixels. This value is sent to the DFP ad server for
targeting.
Declaration
Swift
var height: Int { get }
Objective-C
@property (nonatomic, readonly) NSInteger height;
-
The IMACompanionDelegate for receiving events from the companion ad slot.
-
Initializes an instance of a IMACompanionAdSlot with design ad width and height.
Declaration
Swift
init(view: UIView, width: Int, height: Int)
Objective-C
- (nonnull instancetype)initWithView:(nonnull UIView *)view
width:(NSInteger)width
height:(NSInteger)height;
Parameters
view
|
the UIView that will contain the companion ad
|
width
|
the chosen width of the ad
|
height
|
the chosen height of the ad
|
Return Value
the IMACompanionAdSlot instance
-
Initializes an instance of a IMACompanionAdSlot with fluid size.
Declaration
Objective-C
- (nonnull instancetype)initWithView:(nonnull UIView *)view;
Parameters
view
|
the UIView that will contain the companion ad.
|
Return Value
the IMACompanionAdSlot instance
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\u003eIMACompanionAdSlot\u003c/code\u003e manages companion ads, displayed in a provided UIView container, matched to specified dimensions.\u003c/p\u003e\n"],["\u003cp\u003eIt's crucial to display the designated \u003ccode\u003eview\u003c/code\u003e in your app before the video ad starts for the companion ad to appear.\u003c/p\u003e\n"],["\u003cp\u003eYou can initialize \u003ccode\u003eIMACompanionAdSlot\u003c/code\u003e with fixed dimensions (width & height) or as fluid, adapting to the container.\u003c/p\u003e\n"],["\u003cp\u003eA delegate (\u003ccode\u003eIMACompanionDelegate\u003c/code\u003e) can be assigned to receive events related to the companion ad slot.\u003c/p\u003e\n"],["\u003cp\u003eCompanion ads are unavailable on tvOS, so this class cannot be instantiated on that platform.\u003c/p\u003e\n"]]],[],null,["# GoogleInteractiveMediaAds Framework Reference\n\nIMACompanionAdSlot\n==================\n\n @interface IMACompanionAdSlot : NSObject\n\nAd slot for companion ads. The SDK will put a subview inside the provided\nUIView container. The companion will be matched to the width and height\nprovided here. This class cannot be instantiated on tvOS, where companion ads\nare not available.\n- `\n ``\n ``\n `\n\n ### [view](#/c:objc(cs)IMACompanionAdSlot(py)view)\n\n `\n ` \n The view the companion will be rendered in. Display this view in your\n application before video ad starts. \n\n #### Declaration\n\n Swift \n\n var view: UIView { get }\n\n Objective-C \n\n @property (nonatomic, readonly) UIView *_Nonnull view;\n\n- `\n ``\n ``\n `\n\n ### [width](#/c:objc(cs)IMACompanionAdSlot(py)width)\n\n `\n ` \n Width of the slot, in pixels. This value is sent to the DFP ad server for\n targeting. \n\n #### Declaration\n\n Swift \n\n var width: Int { get }\n\n Objective-C \n\n @property (nonatomic, readonly) NSInteger width;\n\n- `\n ``\n ``\n `\n\n ### [height](#/c:objc(cs)IMACompanionAdSlot(py)height)\n\n `\n ` \n Height of the slot, in pixels. This value is sent to the DFP ad server for\n targeting. \n\n #### Declaration\n\n Swift \n\n var height: Int { get }\n\n Objective-C \n\n @property (nonatomic, readonly) NSInteger height;\n\n- `\n ``\n ``\n `\n\n ### [delegate](#/c:objc(cs)IMACompanionAdSlot(py)delegate)\n\n `\n ` \n The IMACompanionDelegate for receiving events from the companion ad slot. \n\n #### Declaration\n\n Swift \n\n weak var delegate: (any ../Protocols/IMACompanionDelegate.html)? { get set }\n\n Objective-C \n\n @property (nonatomic, weak, nullable) id\u003c../Protocols/IMACompanionDelegate.html\u003e delegate;\n\n- `\n ``\n ``\n `\n\n ### [-initWithView:width:height:](#/c:objc(cs)IMACompanionAdSlot(im)initWithView:width:height:)\n\n `\n ` \n Initializes an instance of a IMACompanionAdSlot with design ad width and height. \n\n #### Declaration\n\n Swift \n\n init(view: UIView, width: Int, height: Int)\n\n Objective-C \n\n - (nonnull instancetype)initWithView:(nonnull UIView *)view\n width:(NSInteger)width\n height:(NSInteger)height;\n\n #### Parameters\n\n |----------------|-----------------------------------------------|\n | ` `*view*` ` | the UIView that will contain the companion ad |\n | ` `*width*` ` | the chosen width of the ad |\n | ` `*height*` ` | the chosen height of the ad |\n\n #### Return Value\n\n the IMACompanionAdSlot instance\n- `\n ``\n ``\n `\n\n ### [-initWithView:](#/c:objc(cs)IMACompanionAdSlot(im)initWithView:)\n\n `\n ` \n Initializes an instance of a IMACompanionAdSlot with fluid size. \n\n #### Declaration\n\n Swift \n\n init(view: UIView)\n\n Objective-C \n\n - (nonnull instancetype)initWithView:(nonnull UIView *)view;\n\n #### Parameters\n\n |--------------|------------------------------------------------|\n | ` `*view*` ` | the UIView that will contain the companion ad. |\n\n #### Return Value\n\n the IMACompanionAdSlot instance"]]