Page History

Ad_interstitial

Last edited by 朱林

获取插屏广告管理类

+ (VLionManager *_Nonnull)manager;

接口定义

创建插屏广告
/**
 插屏广告

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

使用示例

 UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
            view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];

            //创建插屏广告容器
            interstitialV = [[UIView alloc] init];

            UIWindow *window = [[UIApplication sharedApplication].delegate window];

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

            [[VLionManager manager] vl_interstitialWithTagId:@"414"
                                               configuration:cfg
                                                   superView:interstitialV
                                            placeholderImage:[UIImage imageNamed:@"timg.jpg"]
                                              viewController:self
                                               completeBlock:^(UIView * _Nonnull interstitialView, float w, float h, float closeBtnH) {

                                                   interstitialView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width-60, ([UIScreen mainScreen].bounds.size.width-60)*h/w + closeBtnH);
                                                   interstitialV.center = window.center;

            } successBlock:^{

                [view addSubview:interstitialV];
                [window addSubview:view];

            } failedBlock:^(NSDictionary * _Nonnull errorDic) {

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

            } closeBlock:^{
                [[VLionManager manager] vl_destroyBannerOrInterstitialAdvertisement:interstitialV];
                [view removeFromSuperview];

            }];