Wiki
Clone wikiBanner Sample / Multi-size Banner
Multi-Size Banner Placement
Multi-Size banner placements can present banner of varying sizes. For instance it is possible to display a banner of the standard size 320x53, followed by a medium rect angle of size 300x250 within the same placement.
(Note: the green background is an ad container (UIView), into which the placement view is added. It represents the space that is reserved for a multi-size banner placement's view.)
Meta Information
The following sizes are supported for Multi-Size Banner.
- 300x250
- 320x53
- 320x75 (DFP only)
- 320x100 (DFP only)
- 320x150 (DFP only)
- 468x60
- 768x90
Please contact the AddApptr support via support@addapptr.com, in order to let us know which formats you would like to use in your app. The AddApptr team will setup the backend accordingly.
Creating a Multi-Size Banner
A Multi-Size Banner is created by calling the method:
#!swift public static func createMultiSizeBannerPlacement(name: String) -> AATMultiSizeBannerPlacement?
This process is just the same as for the normal banner placement.
Use:
Objective-C:
#!objective-c [AATSDK createMultiSizeBannerPlacementWithName:@"MultiStickyBanner"];
#!swift AATSDK.createMultiSizeBannerPlacement(name: "MultiStickyBanner")
Setting the view controller
You can set the current view controller for AATKit, you should set the viewController in your viewController viewDidAppear
method.
Objective-C:
[AATSDK controllerViewDidAppearWithController:<<your Current ViewController>>];
AATSDK.controllerViewDidAppear(controller: <<your Current ViewController>>)
In the ViewController's viewWillDisappear
method, you should do the following:
Objective-C:
[AATSDK controllerViewWillDisappear];
Swift:
AATSDK.controllerViewWillDisappear()
Requesting an Ad
A Multi-Size Banner supports manual and automatic reload. For manual reload:
placement.reload()
For automatic reload:
placement.startAutoReload()
Listening to events
To register for multisize banner ad events, set the delegate property on AATMultiSizeBannerPlacement
to an object that implements the AATMultiSizeBannerPlacementDelegate
protocol.
Objective-C:
[self.placement setDelegate:self];
Swift:
placement.delegate = self
Implementing AATMultiSizeBannerPlacementDelegate
func aatHaveAdWithBannerView(bannerView: AATBannerPlacementWrapperView) { /// This method will be called when there is an ad } func aatNoAd() { /// This method will be called when there is no ad available } func aatAdCurrentlyDisplayed() { /// This method will be called with the ad display event } func aatResumeAfterAd() { /// This method will be called when the app resumes after displaying an ad }
Displaying a Multi-Size Banner
In order to show a Multi-Size Banner, its view has to be positioned on the screen, similar to regular banner placements. Since a new placement view is provided each time the Multi-Size Banner specific callback is invoked, a potential previous placement view has to be disposed by the programmer, and a new one has to be positioned. Since the UIView frame can change each time Multi-Size Banner callback is invoked the programmer has to adapt the space available according to the view's frame.
Listening to statistics events
AATStatisticsDelegate is an optional delegate you can implement if you need to get notified about statistics events. and pass it to placement while creating it using this
nativePlacement.statisticsDelegate = self
for more info about it please refer to AATStatisticsDelegate Guide
Sample App
Updated