Page History

Ad_banner

Last edited by 朱林

获取横幅广告管理类

+ (VLionManager *_Nonnull)manager;

接口定义

创建横幅广告
/**
 横幅广告

 @param tagId               广告位Id 由vlion提供。请到瑞狮SSP后台获取
 @param configuration       广告显示参数配置,可设置图片类广告view的填充模式
 @param superView           广告父视图(必传)
 @param placeholderImage    占位图(必传)
 @param viewController      当前控制器(必传),若不传,点击广告无法跳转
 @param completeBlock       广告数据请求成功回调  bannerView:广告位容器 w:广告物料的宽(单位px) h:广告物料的高(单位px); 可根据返回物料宽高比重新设置容器的宽高,以免出现广告展示和容器比例不一致问题
 @param successBlock        加载完成回调,建议在此回调中将广告容器添加到要展示的view上
 @param failedBlock         失败回调
 @param adClickBlock        点击广告
 @param adBackBlock         web类广告返回
 */
- (void)vl_bannerWithTagId:(NSString *_Nonnull)tagId
             configuration:(VLionAdConfiguration *_Nonnull)configuration
                 superView:(UIView *_Nonnull)superView
          placeholderImage:(UIImage *_Nonnull)placeholderImage
            viewController:(UIViewController *_Nonnull)viewController
             completeBlock:(void(^_Nullable)(UIView *_Nullable bannerView, float w, float h))completeBlock
              successBlock:(void(^_Nullable)(void))successBlock
               failedBlock:(void(^_Nullable)(NSDictionary *_Nullable errorDic))failedBlock;
销毁并移除广告
- (void)vl_destroyBannerOrInterstitialAdvertisement:(UIView *_Nonnull)superView;

使用示例

 //广告容器
    bannerV = [[UIView alloc] init];

    VLionAdConfiguration *cfg = [VLionAdConfiguration defaultConfiguration];
    //配置图片类广告的填充模式
    cfg.contentMode = UIViewContentModeScaleAspectFit;

    [[VLionManager manager] vl_bannerWithTagId:@"424"
                                 configuration:cfg
                                     superView:bannerV
                              placeholderImage:[UIImage imageNamed:@"timg.jpg"]
                                viewController:self
                                 completeBlock:^(UIView * _Nonnull bannerView, float w, float h) {

                                     bannerView.frame = CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*h/w);

    } successBlock:^{

        [self.view addSubview:bannerV];
        [self.view bringSubviewToFront:button];

    } failedBlock:^(NSDictionary * _Nonnull errorDic) {

        NSLog(@"banner errorDic --------- (%@)", errorDic);

    }];

}

- (void)closeAction {
    [[VLionManager manager] vl_destroyBannerOrInterstitialAdvertisement:bannerV];
    [self dismissViewControllerAnimated:YES completion:NULL];
}