广点通开屏广告接入的坑

广点通开发文档里给的示例代码:

GDTSplashAd *splash = [[GDTSplashAd alloc] initWithAppkey: YOUR_APP_ID placementId:YOUR_PLACEMENT_ID];

  splash.delegate = self; //设置代理

  //根据iPhone设备不同设置不同背景图

  if ([[UIScreen mainScreen] bounds].size.height >= 568.0f) {

  splash.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"LaunchImage-568h"]];

  } else {

  splash.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"LaunchImage"]];

  }

  splash.fetchDelay = 3; //开发者可以设置开屏拉取时间,超时则放弃展示

  //[可选]拉取并展示全屏开屏广告

  //[splashAd loadAdAndShowInWindow:self.window];

  //设置开屏底部自定义LogoView,展示半屏开屏广告

  _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 100)];

  UIImageView *logo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SplashBottomLogo"]];

  [_bottomView addSubview:logo];

  logo.center = _bottomView.center;

  _bottomView.backgroundColor = [UIColor whiteColor];

****这里有个坑,就是GDTSplashAd *splash不能这样创建一个GDTSplashAd临时变量,而必须将splash定义成一个strong属性变量:

@property (strong, nonatomic) GDTSplashAd *splash;

否则会发现,可以加载开屏广告,但回调事件不正常,广告加载,计时归零后不会自动消失;同时也无法点击广告;

详情

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌。在这里你可以看...
    F麦子阅读 5,166评论 5 13
  • //设置尺寸为屏幕尺寸的时候self.window = [[UIWindow alloc] initWithFra...
    LuckTime阅读 865评论 0 0
  • #import "ViewController.h"#import "OneViewController.h"#d...
    dcbcb9d3f253阅读 310评论 0 0
  • IOS常用代码总结 1、设置UILabel行间距 NSMutableAttributedString* attrS...
    难却却阅读 602评论 0 0
  • 身边熟悉我的人,在刚刚过去的那个秋天,都对我避之不及,因为我失恋了,遇到任何人都想一诉解忧愁,像个祥林嫂一般,叨叨...
    胡子编小辫儿阅读 239评论 1 0