Banner and MREC ads are rectangular ad formats that occupy part of an app’s layout—often at the top or bottom of the screen or inline in scrollable content. They remain visible as users interact with the app, which allows uninterrupted gameplay or use, and can refresh automatically after a set period.
The following sections show you how to load, show, and hide a banner or MREC ad.
“Why mobile banners ads persist in a video and playable world” from AppLovin’s Blog.
If your integration requires displaying MREC ads in a content feed, AppLovin recommends this technique:
loadAd (re-use the MAAdView instances).You can find an example implementation in the AppLovin demo app (Objective-C, Swift).
To load a banner, create a MAAdView object that corresponds to your ad unit and call its loadAd method.
To show that ad, add the MAAdView object as a subview of your view hierarchy.
Implement MAAdViewAdDelegate so that you are notified when your ad is ready.
This also notifies you of other ad-related events.
#import "ExampleViewController.h"
#import <AppLovinSDK/AppLovinSDK.h>
@interface ExampleViewController()<MAAdViewAdDelegate>
@property (nonatomic, strong) MAAdView *adView;
@end
@implementation ExampleViewController
- (void)createBannerAd
{
self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: @"«ad-unit-ID»"];
self.adView.delegate = self;
// Banner height on iPhone and iPad is 50 and 90, respectively
CGFloat height = (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) ? 90 : 50;
// Stretch to the width of the screen for banners to be fully functional
CGFloat width = CGRectGetWidth(UIScreen.mainScreen.bounds);
self.adView.frame = CGRectMake(x, y, width, height);
// Set background color for banners to be fully functional
self.adView.backgroundColor = «background-color»;
[self.view addSubview: self.adView];
// Load the ad
[self.adView loadAd];
}
#pragma mark - MAAdDelegate Protocol
- (void)didLoadAd:(MAAd *)ad {}
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error {}
- (void)didClickAd:(MAAd *)ad {}
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error {}
#pragma mark - MAAdViewAdDelegate Protocol
- (void)didExpandAd:(MAAd *)ad {}
- (void)didCollapseAd:(MAAd *)ad {}
#pragma mark - Deprecated Callbacks
- (void)didDisplayAd:(MAAd *)ad { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
- (void)didHideAd:(MAAd *)ad { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
@end
To load a banner, create a MAAdView object that corresponds to your ad unit and call its loadAd method.
To show that ad, add the MAAdView object as a subview of your view hierarchy.
Implement MAAdViewAdDelegate so that you are notified when your ad is ready.
This also notifies you of other ad-related events.
class ExampleViewController: UIViewController, MAAdViewAdDelegate
{
var adView: MAAdView!
func createBannerAd()
{
adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»")
adView.delegate = self
// Banner height on iPhone and iPad is 50 and 90, respectively
let height = (UIDevice.current.userInterfaceIdiom == .pad) ? 90 : 50
// Stretch to the width of the screen for banners to be fully functional
let width = UIScreen.main.bounds.width
adView.frame = CGRect(x: x, y: y, width: width, height: height)
// Set background color for banners to be fully functional
adView.backgroundColor = «background-color»
view.addSubview(adView)
// Load the first ad
adView.loadAd()
}
// MARK: MAAdDelegate Protocol
func didLoad(_ ad: MAAd) {}
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError) {}
func didClick(_ ad: MAAd) {}
func didFail(toDisplay ad: MAAd, withError error: MAError) {}
// MARK: MAAdViewAdDelegate Protocol
func didExpand(_ ad: MAAd) {}
func didCollapse(_ ad: MAAd) {}
// MARK: Deprecated Callbacks
func didDisplay(_ ad: MAAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
func didHide(_ ad: MAAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
}To load a banner, create a UIViewRepresentable object, a wrapper that lets you integrate MAAdView, a UIKit view type object, into your SwiftUI view hierarchy.
Also provide a custom Coordinator class for the wrapper object that conforms to MAAdViewAdDelegate.
This notifies you when your ad is ready, and notifies you of other ad-related events.
Inside the wrapper’s makeUIView method, create a MAAdView object that corresponds to your ad unit.
Call its loadAd method.
To show that ad, add the UIViewRepresentable wrapper object inside your SwiftUI view hierarchy.
You can find implementation examples in the AppLovin-MAX_SDK_iOS Github repository.
struct ExampleSwiftUIWrapper: UIViewRepresentable
{
func makeUIView(context: Context) -> MAAdView
{
let adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»")
adView.delegate = context.coordinator
// Set background color for banners to be fully functional
adView.backgroundColor = «background-color»
// Load the first Ad
adView.loadAd()
return adView
}
func updateUIView(_ uiView: MAAdView, context: Context) {}
func makeCoordinator() -> Coordinator
{
Coordinator()
}
}
extension ExampleSwiftUIWrapper
{
class Coordinator: NSObject, MAAdViewAdDelegate
{
// MARK: MAAdDelegate Protocol
func didLoad(_ ad: MAAd) {}
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError) {}
func didClick(_ ad: MAAd) {}
func didFail(toDisplay ad: MAAd, withError error: MAError) {}
// MARK: MAAdViewAdDelegate Protocol
func didExpand(_ ad: MAAd) {}
func didCollapse(_ ad: MAAd) {}
// MARK: Deprecated Callbacks
func didDisplay(_ ad: MAAd) { /* use this for impression tracking */ }
func didHide(_ ad: MAAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
}
}
// SwiftUI view to show ad
struct ExampleSwiftUIBannerAdView: View
{
// Banner height on iPhone and iPad is 50 and 90, respectively
let height = (UIDevice.current.userInterfaceIdiom == .pad) ? 90 : 50
// Stretch to the width of the screen for banners to be fully functional
let width = UIScreen.main.bounds.width
var body: some View {
ExampleSwiftUIWrapper()
.frame(width: width, height: height)
}
}To load an MREC ad, create a MAAdView object corresponding to your ad unit and call its loadAd method.
To show the ad, add the MAAdView object as a subview of your view hierarchy.
Implement MAAdViewAdDelegate so that you are notified when your ad is ready.
This also notifes you of other ad-related events.
#import "ExampleViewController.h"
#import <AppLovinSDK/AppLovinSDK.h>
@interface ExampleViewController()<MAAdViewAdDelegate>
@property (nonatomic, strong) MAAdView *adView;
@end
@implementation ExampleViewController
- (void)createMRecAd
{
self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: @"«ad-unit-ID»" adFormat: MAAdFormat.mrec];
self.adView.delegate = self;
// MREC width and height are 300 and 250 respectively, on iPhone and iPad
CGFloat width = 300;
CGFloat height = 250;
// Center the MREC
CGFloat x = self.view.center.x - 150;
self.adView.frame = CGRectMake(x, y, width, height);
// Set background color for MREC ads to be fully functional
self.adView.backgroundColor = «background-color»;
[self.view addSubview: self.adView];
// Load the ad
[self.adView loadAd];
}
#pragma mark - MAAdDelegate Protocol
- (void)didLoadAd:(MAAd *)ad {}
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error {}
- (void)didClickAd:(MAAd *)ad {}
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error {}
#pragma mark - MAAdViewAdDelegate Protocol
- (void)didExpandAd:(MAAd *)ad {}
- (void)didCollapseAd:(MAAd *)ad {}
#pragma mark - Deprecated Callbacks
- (void)didDisplayAd:(MAAd *)ad { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
- (void)didHideAd:(MAAd *)ad { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
@end
To load an MREC ad, create a MAAdView object corresponding to your ad unit and call its loadAd method.
To show the ad, add the MAAdView object as a subview of your view hierarchy.
Implement MAAdViewAdDelegate so that you are notified when your ad is ready.
This also notifies you of other ad-related events.
class ExampleViewController: UIViewController, MAAdViewAdDelegate
{
var adView: MAAdView!
func createMRecAd()
{
adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»", adFormat: MAAdFormat.mrec)
adView.delegate = self
// MREC width and height are 300 and 250 respectively, on iPhone and iPad
let height = 250
let width = 300
adView.frame = CGRect(x: x, y: y, width: width, height: height)
// Center the MREC
adView.center.x = view.center.x
// Set background color for MREC ads to be fully functional
adView.backgroundColor = «background-color»
view.addSubview(adView)
// Load the first ad
adView.loadAd()
}
// MARK: MAAdDelegate Protocol
func didLoad(_ ad: MAAd) {}
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError) {}
func didClick(_ ad: MAAd) {}
func didFail(toDisplay ad: MAAd, withError error: MAError) {}
// MARK: MAAdViewAdDelegate Protocol
func didExpand(_ ad: MAAd) {}
func didCollapse(_ ad: MAAd) {}
// MARK: Deprecated Callbacks
func didDisplay(_ ad: MAAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
func didHide(_ ad: MAAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
}To load an MREC ad, first create a UIViewRepresentable object, a wrapper that lets you integrate MAAdView, a UIKit view type object, into your SwiftUI view hierarchy.
Also provde a custom Coordinator class for the wrapper object that conforms to MAAdViewAdDelegate.
This notifies you when your ad is ready, and notifies you of other ad-related events.
Inside the wrapper’s makeUIView method, create a MAAdView object that corresponds to your ad unit and call its loadAd method.
To show that ad, add the UIViewRepresentable wrapper object inside your SwiftUI view hierarchy.
You can find implementation examples in the AppLovin-MAX_SDK_iOS Github repository.
struct ExampleSwiftUIWrapper: UIViewRepresentable
{
func makeUIView(context: Context) -> MAAdView
{
let adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»", adFormat: MAAdFormat.mrec)
adView.delegate = context.coordinator
// Set background color for banners to be fully functional
adView.backgroundColor = «background-color»
// Load the first Ad
adView.loadAd()
return adView
}
func updateUIView(_ uiView: MAAdView, context: Context) {}
func makeCoordinator() -> Coordinator
{
Coordinator()
}
}
extension ExampleSwiftUIWrapper
{
class Coordinator: NSObject, MAAdViewAdDelegate
{
// MARK: MAAdDelegate Protocol
func didLoad(_ ad: MAAd) {}
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError) {}
func didClick(_ ad: MAAd) {}
func didFail(toDisplay ad: MAAd, withError error: MAError) {}
// MARK: MAAdViewAdDelegate Protocol
func didExpand(_ ad: MAAd) {}
func didCollapse(_ ad: MAAd) {}
// MARK: Deprecated Callbacks
func didDisplay(_ ad: MAAd) { /* use this for impression tracking */ }
func didHide(_ ad: MAAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
}
}
// SwiftUI view to show ad
struct ExampleSwiftUIMRECAdView: View
{
// MREC width and height are 300 and 250 respectively, on iPhone and iPad
let height = 250
let width = 300
var body: some View {
ExampleSwiftUIWrapper()
.frame(width: width, height: height)
}
}You may no longer need a MAAdView instance.
This may happen, for example, if the user purchases ad removal.
Deallocate such a MAAdView instance to free resources.
Do not deallocate the MAAdView instance if you use multiple instances with the same Ad Unit ID.
[self.adView removeFromSuperview];
self.adView.delegate = nil;
self.adView = nil;
adView.removeFromSuperview()
adView.delegate = nil
adView = nilGoogle bidding and Google AdMob, Google Ad Manager, Liftoff Monetize, Pangle, and Yandex support adaptive banners. MAX sizes banners from other networks in the non-adaptive way.
Google recommends that developers include a 50 px padding between the banner placement and the app content. This makes it less likely that users accidentally click the banner. Refer to Google’s “About Confirmed Click” policy for more information and best practices.
Adaptive banners are responsive ads that dynamically adjust their dimensions based on device type and available width. Adaptive banners can be either anchored or inline, with each type serving specific integration needs.
Starting in MAX SDK version 13.2.0, you can integrate adaptive banners by initializing your MAAdView with a MAAdViewConfiguration object for which you set an adaptiveType at build-time.
The following adapters support special adaptive banner features:
| Network | Adapter Versions | Special Feature |
|---|---|---|
| Google Ad Manager | 11.7.0.1+ | Inline adaptive banners |
| 11.13.0.1+ | Inline adaptive MRECs | |
| 10.2.0.1+ | Setting a custom width | |
| Google Bidding and Google AdMob | 11.7.0.1+ | Inline adaptive banners |
| 11.13.0.1+ | Inline adaptive MRECs | |
| 10.2.0.2+ | Setting a custom width | |
| Liftoff Monetize | 7.4.5.1+ | |
| Pangle | 7.1.0.8.0+ | |
| Yandex | 7.12.2.1+ |
Anchored adaptive banners are those you anchor at the top or bottom of the screen. They dynamically adjust their height based on the device type and the banner width.
You must set the height of the MAAdView to the value returned by MAAdFormat.banner.adaptiveSize.height instead of using a constant value like 50 or 90.
- (void)createAnchoredAdaptiveBannerAd
{
// Stretch to the width of the screen for banners to be fully functional
CGFloat width = CGRectGetWidth(UIScreen.mainScreen.bounds);
// Get the anchored adaptive banner height
CGFloat height = MAAdFormat.banner.adaptiveSize.height;
MAAdViewConfiguration *config = [MAAdViewConfiguration configurationWithBuilderBlock:^(MAAdViewConfigurationBuilder *builder) {
builder.adaptiveType = MAAdViewAdaptiveTypeAnchored;
}];
self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: @"«ad-unit-ID»" configuration: config];
self.adView.delegate = self;
self.adView.frame = CGRectMake(x, y, width, height);
// Set background color for banners to be fully functional
self.adView.backgroundColor = «background-color»;
[self.view addSubview: self.adView];
// Load the ad
[self.adView loadAd];
}
func createAnchoredAdaptiveBannerAd()
{
// Stretch to the width of the screen for banners to be fully functional
let width = UIScreen.main.bounds.width
// Get the anchored adaptive banner height.
let height = MAAdFormat.banner.adaptiveSize.height
let config = MAAdViewConfiguration { builder in
builder.adaptiveType = .anchored
}
adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»", configuration: config)
adView.delegate = self
adView.frame = CGRect(x: x, y: y, width: width, height: height)
// Set background color for banners to be fully functional
adView.backgroundColor = «background-color»
view.addSubview(adView)
// Load the first ad
adView.loadAd()
}struct ExampleSwiftUIWrapper: UIViewRepresentable
{
func makeUIView(context: Context) -> MAAdView
{
let config = MAAdViewConfiguration { builder in
builder.adaptiveType = .anchored
}
let adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»", configuration: config)
adView.delegate = context.coordinator
// Set background color for banners to be fully functional
adView.backgroundColor = «background-color»
// Load the first Ad
adView.loadAd()
return adView
}
⋮
}
// SwiftUI view to show ad
struct ExampleSwiftUIAdaptiveBannerAdView: View
{
// Stretch to the width of the screen for banners to be fully functional
let width = UIScreen.main.bounds.width
// Get the anchored adaptive banner height
let height = MAAdFormat.banner.adaptiveSize.height
var body: some View {
ExampleSwiftUIWrapper()
.frame(width: width, height: height)
}
}For more specific integrations, you can configure a custom width in points by setting a MAAdViewConfiguration builder option.
To fetch the appropriate height for your custom anchored adaptive ad, call the adaptive size API.
CGFloat width = 400;
// Get the anchored adaptive banner height
CGFloat height = [self.adView.adFormat adapativeSizeForWidth: width].height;
MAAdViewConfiguration *config = [MAAdViewConfiguration configurationWithBuilderBlock:^(MAAdViewConfigurationBuilder *builder) {
builder.adaptiveType = MAAdViewAdaptiveTypeAnchored;
builder.adaptiveWidth = width;
}];
self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: @"«ad-unit-ID»" configuration: config];
let width = 400
// Get the anchored adaptive banner height
let height = adView.adFormat.adaptiveSize(forWidth: width).height
let config = MAAdViewConfiguration { builder in
builder.adaptiveType = .anchored
builder.adaptiveWidth = width
}
adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»", configuration: config)let width = 400
// Get the anchored adaptive banner height
let height = adView.adFormat.adaptiveSize(forWidth: width).height
let config = MAAdViewConfiguration { builder in
builder.adaptiveType = .anchored
builder.adaptiveWidth = width
}
let adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»", configuration: config)
⋮Adaptive banners are anchored by default. You can also enable inline adaptive banners, which you can place in scrollable content. Inline adaptive banners are typically larger than anchored adaptive banners. They have variable heights that can extend to the full height of the device screen.
To enable inline adaptive banners, set the MAAdViewConfiguration adaptive type to MAAdViewAdaptiveTypeInline as shown in the code below:
MAAdViewConfiguration *config = [MAAdViewConfiguration configurationWithBuilderBlock:^(MAAdViewConfigurationBuilder *builder) {
builder.adaptiveType = MAAdViewAdaptiveTypeInline;
⋮
}];
let config = MAAdViewConfiguration { builder in
builder.adaptiveType = .inline
⋮
}let config = MAAdViewConfiguration { builder in
builder.adaptiveType = .inline
⋮
}The default maximum height for an inline adaptive ad is the entire height of the device screen.
You may want to set a maximum height, in points, for your inline adaptive ad to ensure that the ad fits in the height of the MAAdView.
You can do this with code like the following, which uses a maximum height of 100 points as an example:
MAAdViewConfiguration *config = [MAAdViewConfiguration configurationWithBuilderBlock:^(MAAdViewConfigurationBuilder *builder) {
builder.adaptiveType = MAAdViewAdaptiveTypeInline;
builder.inlineMaximumHeight = 100;
⋮
}];
let config = MAAdViewConfiguration { builder in
builder.adaptiveType = .inline
builder.inlineMaximumHeight = 100
⋮
}let config = MAAdViewConfiguration { builder in
builder.adaptiveType = .inline
builder.inlineMaximumHeight = 100
⋮
}Inline adaptive MRECs span the full width of the application window by default, but you may optionally specify a custom width in points. The height is variable and can extend beyond standard MREC dimensions up to the full height of the device screen if you do not specify a maximum height.
To enable inline adaptive MRECs, set the MAAdViewConfiguration adaptive type to MAAdViewAdaptiveTypeInline as shown in the code below:
- (void)createInlineAdaptiveMRecAd
{
// Set a custom width, in points, for the inline adaptive MREC. Otherwise stretch to screen width by using CGRectGetWidth(UIScreen.mainScreen.bounds)
CGFloat width = 400;
// Set a maximum height, in points, for the inline adaptive MREC. Otherwise use standard MREC height of 250 points
// Google recommends a height greater than 50 points, with a minimum of 32 points and a maximum equal to the screen height
// The value must also not exceed the height of the MAAdView
CGFloat height = 300;
MAAdViewConfiguration *config = [MAAdViewConfiguration configurationWithBuilderBlock:^(MAAdViewConfigurationBuilder *builder) {
builder.adaptiveType = MAAdViewAdaptiveTypeInline;
builder.adaptiveWidth = width; // Optional: The adaptive ad spans the width of the application window if you do not set a value
builder.inlineMaximumHeight = height; // Optional: The maximum height is the screen height if you do not set a value
}];
self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: @"«ad-unit-ID»" adFormat: MAAdFormat.mrec configuration: config];
self.adView.delegate = self;
self.adView.frame = CGRectMake(x, y, width, height);
// Set background color for adaptive MRECs to be fully functional
self.adView.backgroundColor = «background-color»;
[self.view addSubview: self.adView];
// Load the ad
[self.adView loadAd];
}
func createInlineAdaptiveMRecAd()
{
// Set a custom width, in points, for the inline adaptive MREC. Otherwise stretch to screen width by using UIScreen.main.bounds.width
let width = 400
// Set a maximum height, in points, for the inline adaptive MREC. Otherwise use standard MREC height of 250 points
// Google recommends a height greater than 50 points, with a minimum of 32 points and a maximum equal to the screen height
// The value must also not exceed the height of the MAAdView
let height = 300
let config = MAAdViewConfiguration { builder in
builder.adaptiveType = .inline
builder.adaptiveWidth = width // Optional: The adaptive ad spans the width of the application window if you do not set a value
builder.inlineMaximumHeight = height // Optional: The maximum height is the screen height if you do not set a value
}
adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»", adFormat: MAAdFormat.mrec, configuration: config)
adView.delegate = self
adView.frame = CGRect(x: x, y: y, width: width, height: height)
// Set background color for adaptive MRECs to be fully functional
adView.backgroundColor = «background-color»
view.addSubview(adView)
// Load the first ad
adView.loadAd()
}struct ExampleSwiftUIWrapper: UIViewRepresentable
{
let width: CGFloat
let height: CGFloat
func makeUIView(context: Context) -> MAAdView
{
let config = MAAdViewConfiguration { builder in
builder.adaptiveType = .inline
builder.adaptiveWidth = width // Optional: The adaptive ad spans the width of the application window if you do not set a value
builder.inlineMaximumHeight = height // Optional: The maximum height is the screen height if you do not set a value
}
let adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»", adFormat: MAAdFormat.mrec, configuration: config)
adView.delegate = context.coordinator
// Set background color for adaptive MRECs to be fully functional
adView.backgroundColor = «background-color»
// Load the first ad
adView.loadAd()
return adView
}
⋮
}
struct ExampleSwiftUIInlineAdaptiveMRecAdView: View
{
// Set a custom width, in points, for the inline adaptive MREC. Otherwise stretch to screen width by using UIScreen.main.bounds.width
let width = 400
// Set a maximum height, in points, for the inline adaptive MREC. Otherwise use standard MREC height of 250 points
// Google recommends a height greater than 50 points, with a minimum of 32 points and a maximum equal to the screen height
// The value must also not exceed the height of the MAAdView
let height = 300
var body: some View {
ExampleSwiftUIWrapper(width: width, height: height)
.frame(width: width, height: height)
}
}The adaptive ad you load could be smaller than the dimensions you requested. You may wish to configure your UI in a way that can adapt based on the size of the adaptive ad served. If so, you can retrieve the width and height of the loaded ad, in points, with code like the following:
- (void)didLoadAd:(MAAd *)ad
{
CGSize adViewSize = ad.size;
CGFloat width = adViewSize.width;
CGFloat height = adViewSize.height;
⋮
}
func didLoad(_ ad: MAAd)
{
let adViewSize = ad.size
let width = adViewSize.width
let height = adViewSize.height
⋮
}func didLoad(_ ad: MAAd)
{
let adViewSize = ad.size
let width = adViewSize.width
let height = adViewSize.height
⋮
}You may want to stop auto-refresh for an ad. You may want to do this, for instance, when you hide a banner ad or you want to manually refresh. Stop auto-refresh for a banner or MREC ad with the following code:
// Set this extra parameter to work around SDK bug that ignores calls to stopAutoRefresh()
[adView setExtraParameterForKey: @"allow_pause_auto_refresh_immediately" value: @"true"];
[adView stopAutoRefresh];
// Set this extra parameter to work around SDK bug that ignores calls to stopAutoRefresh()
adView.setExtraParameterForKey("allow_pause_auto_refresh_immediately", value: "true")
adView.stopAutoRefresh()// Set this extra parameter to work around SDK bug that ignores calls to stopAutoRefresh()
adView.setExtraParameterForKey("allow_pause_auto_refresh_immediately", value: "true")
adView.stopAutoRefresh()Start auto-refresh for a banner or MREC ad with the following call:
[adView startAutoRefresh];
adView.startAutoRefresh()
adView.startAutoRefresh()
Manually refresh the contents with the following call.
You must stop auto-refresh before you call loadAd().
[adView loadAd];
adView.loadAd()
adView.loadAd()