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-01-14 UTC.
[null,null,["Last updated 2025-01-14 UTC."],[[["\u003cp\u003e\u003ccode\u003eIMACompanionAdSlot\u003c/code\u003e manages companion ads, displaying them within a designated UIView container.\u003c/p\u003e\n"],["\u003cp\u003eIt uses specified width and height for ad targeting and matching.\u003c/p\u003e\n"],["\u003cp\u003eCompanion ads are not available on tvOS.\u003c/p\u003e\n"],["\u003cp\u003eInitialization can be done with fixed dimensions or fluid size using a designated UIView.\u003c/p\u003e\n"],["\u003cp\u003eAn optional delegate can be set for receiving companion ad events.\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"]]