橫幅廣告

橫幅廣告

以下說明適用於 v4.0.0 以後的版本。

開始使用


ViewController.h

#import "AdbertADBanner.h"

@interface ViewController : UIViewController <AdbertADBannerDelegate>
@property(nonatomic, strong) AdbertADBanner *banner;

ViewController.m

//請輸入與 ADBERT 申請的 APPID 與 APPKEY
NSString *appID = @"";
NSString *appKey = @"";
self.banner = [[AdbertADBanner alloc] initWithAPPID:appID AndAPPKEY:appKey];

//設定廣告大小及比例
CGFloat adScale = 50/320; //廣告比例
CGFloat adWidth = [UIScreen mainScreen].bounds.size.width; //廣告寬度,此為全螢幕寬度
CGFloat adHeight = adWidth * adScale; //廣告高度
self.banner.adSize = CGSizeMake(adWidth, adHeight);

//設定廣告位置及大小
[self.banner setFrame:CGRectMake(0, 0, adWidth, adHeight)];
self.banner.delegate = self;
[view addSubview:self.banner];

//請求廣告,初始化廣告
[self.banner requestAD];
接收成功與 Show 廣告

- (void)adbertADViewDidReceiveAd:(AdbertADBanner *)banner {
    NSLog(@"# Adbert AD banner ad did received.");
    [banner showAD];
}
接收失敗

- (void)adbertADView:(AdbertADBanner *)banner didFailToReceiveAdWithError:(NSError *)error {
    NSLog(@"# Adbert AD banner ad did Fail.");
    NSLog(@"# error -> %@", error);
}