Implement banner ads in iOS
Implement banner ads in your iOS app. Create and display banner view objects within your view hierarchy, and use a delegate to manage ad events.
Read time 1 minuteLast updated a day ago
You can place the banner view object into your view hierarchy, just like you would any other view. This allows you to customize the position of each banner instance, or display multiple banners.
Script implementation
The following script sample is an example implementation for displaying two banner ads on the screen. For more information on the classes referenced, refer to theUADSBannerAdImplementing the MREC banner format
To display a medium rectangle (MREC) sized ad format in your app, ensure the proper dimensions are used, such as 300x250, 300x300, or 450x450. In the case of a 300x250 MREC banner ad specifically, replace this in the following example code:
With this adjusted dimension:CGSizeMake(320, 50)
CGSizeMake(300, 250)
Banner ad load example
@interface MyDelegate : NSObject <UADSBannerAdDelegate>@end@implementation MyDelegate- (void)bannerImpression:(UADSBannerAd *)banner {}- (void)bannerDidClick:(UADSBannerAd *)banner {}- (void)bannerDidFailShow:(UADSBannerAd *)banner error:(id<UnityAdsError>)error {}@end@property (strong) UADSBannerAd *bannerAd;UADSBannerLoadConfigurationBuilder *builder =[[UADSBannerLoadConfigurationBuilder alloc]initWithPlacementId:placementId bannerSize:CGSizeMake(320, 50) delegate:delegate];builder = [builder withMediationInfo:self.mediationInfo];builder = [builder withAdMarkup:bidResponse];[UADSBannerAd load:[builder build] completion:^(UADSBannerAd *ad, id<UnityAdsError> error) {if (!error) { self.bannerAd = ad; [container addSubview:ad.view];}}];