确认AdColony SDK已经成功添加到项目中,包含AdColony.framework文件。
导入AdColony的头文件:
#import
_adBannerView = [[AdColonyAdView alloc] initWithZoneID:@"Your_AdZone_ID" frame:CGRectMake(0, UIScreen.mainScreen.bounds.size.height-50, UIScreen.mainScreen.bounds.size.width, 50)];
其中,Your_AdZone_ID为AdColony平台上的广告位ID。
[self.view addSubview:_adBannerView];
[_adBannerView load];
#pragma mark - AdColonyAdViewDelegate
(void)adColonyAdViewDidReceiveAd:(AdColonyAdView *)adView { NSLog(@"AdColony banner Ad did load"); }
(void)adColonyAdView:(AdColonyAdView *)adView didFailToLoadWithError:(NSError *)error { NSLog(@"AdColony banner Ad failed to load with error: %@", error.localizedDescription); }
(void)adColonyAdViewWillLeaveApplication:(AdColonyAdView *)adView { NSLog(@"AdColony banner Ad will leave application"); }
[_adBannerView removeFromSuperview]; _adBannerView.delegate = nil; _adBannerView = nil;
由于AdColony横幅广告有自己的请求和展示规则,如果因为一些原因无法展示,也不会出现错误提示。但是可以通过以上协议方法来接收错误信息和展示状态。