廣點(diǎn)通開(kāi)發(fā)文檔里給的示例代碼:
GDTSplashAd *splash = [[GDTSplashAd alloc] initWithAppkey: YOUR_APP_ID placementId:YOUR_PLACEMENT_ID];
? splash.delegate = self; //設(shè)置代理
? //根據(jù)iPhone設(shè)備不同設(shè)置不同背景圖
? 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; //開(kāi)發(fā)者可以設(shè)置開(kāi)屏拉取時(shí)間,超時(shí)則放棄展示
? //[可選]拉取并展示全屏開(kāi)屏廣告
? //[splashAd loadAdAndShowInWindow:self.window];
? //設(shè)置開(kāi)屏底部自定義LogoView,展示半屏開(kāi)屏廣告
? _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];
****這里有個(gè)坑,就是GDTSplashAd *splash不能這樣創(chuàng)建一個(gè)GDTSplashAd臨時(shí)變量,而必須將splash定義成一個(gè)strong屬性變量:
@property (strong, nonatomic) GDTSplashAd *splash;
否則會(huì)發(fā)現(xiàn),可以加載開(kāi)屏廣告,但回調(diào)事件不正常,廣告加載,計(jì)時(shí)歸零后不會(huì)自動(dòng)消失;同時(shí)也無(wú)法點(diǎn)擊廣告;