iad admob整合代码



#pragma mark iAd

- (void)addIAdBanner {

// if place the banner on the bottom

// adView = [[ADBannerView alloc] initWithFrame:CGRectZero];



adView = [[ADBannerView alloc] initWithFrame:CGRectMake(320 - (32 / 2) - 480 / 2, 480 / 2 - (50 - (32 / 2)), 0, 0)];



adView.frame = CGRectOffset(adView.frame, 32, 0); // hide



adView.delegate = self;

adView.requiredContentSizeIdentifiers = [NSSet setWithObjects:ADBannerContentSizeIdentifier320x50, ADBannerContentSizeIdentifier480x32, nil];

adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier480x32;

[[[CCDirector sharedDirector] openGLView] addSubview:adView];



// Transform iAd

adView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));



iAdBannerIsVisible = NO;

}


- (void)removeIAdBanner {

// clear iAd

adView.delegate = nil;

[adView removeFromSuperview];

[adView release];

adView = nil;



iAdBannerIsVisible = NO;

}


- (void)bannerViewDidLoadAd:(ADBannerView *)banner {

NSLog(@"[iAd]: Ad did load.");



if (!iAdBannerIsVisible) {

adView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));



adView.frame = CGRectOffset(adView.frame, -32, 0);



adView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));



iAdBannerIsVisible = YES;

}



if (admobBannerIsVisible) {

// hide it

adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));

adMobAd.frame = CGRectMake(140 + 48, 215, 320, 48);

adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));

}

}


- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {

NSLog(@"[iAd]: Faild to load the banner: %@", error);



if (iAdBannerIsVisible) {

adView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));

adView.frame = CGRectOffset(adView.frame, 32, 0);

adView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));



iAdBannerIsVisible = NO;

}



if (admobBannerIsVisible) {

// show it

adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));

adMobAd.frame = CGRectMake(140, 215, 320, 48);

adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));

}

}


- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave {

NSLog(@"[iAd]: An action was started from the banner. Application will quit: %d", willLeave);



return YES;

}


- (void)bannerViewActionDidFinish:(ADBannerView *)banner {

NSLog(@"[iAd]: Action finished.");

}

#pragma mark AdMobDelegate methods


- (NSString *)publisherIdForAd:(AdMobView *)adView {

return @"a14c561cd7cbb82"; // this should be prefilled; if not, get it from www.admob.com

}


- (UIViewController *)currentViewControllerForAd:(AdMobView *)adView {

return controller;

}


- (UIColor *)adBackgroundColorForAd:(AdMobView *)adView {

return [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; // this should be prefilled; if not, provide a UIColor

}


- (UIColor *)primaryTextColorForAd:(AdMobView *)adView {

return [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; // this should be prefilled; if not, provide a UIColor

}


- (UIColor *)secondaryTextColorForAd:(AdMobView *)adView {

return [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; // this should be prefilled; if not, provide a UIColor

}


// Sent when an ad request loaded an ad; this is a good opportunity to attach

// the ad view to the hierachy.

- (void)didReceiveAd:(AdMobView *)adView {

NSLog(@"AdMob: Did receive ad");



adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));

adMobAd.frame = CGRectMake(140, 215, 320, 48);

adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));



if (iAdBannerIsVisible) {

// if iAdBannerIsVisible, hide admob banner

adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));

adMobAd.frame = CGRectMake(140 + 48, 215, 320, 48);

adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));

}



[[[CCDirector sharedDirector] openGLView] addSubview:adMobAd];



[refreshTimer invalidate];

refreshTimer = [NSTimer scheduledTimerWithTimeInterval:AD_REFRESH_PERIOD target:self selector:@selector(refreshAd:) userInfo:nil repeats:YES];



admobBannerIsVisible = YES;

}


// Sent when an ad request failed to load an ad

- (void)didFailToReceiveAd:(AdMobView *)adView {

NSLog(@"field receive admob.");



[adMobAd removeFromSuperview];



[self performSelector:@selector(requestAd) withObject:nil afterDelay:2.0];



admobBannerIsVisible = NO;

}


- (void)refreshAd:(ccTime)dt {

NSLog(@"refresh admob.");



[adMobAd requestFreshAd];

}


- (void)requestAd {

adMobAd = [AdMobView requestAdWithDelegate:self];

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
华为iad132用户手册是一本详细介绍华为iad132产品的使用方法和操作指南的手册。该手册内容丰富,清晰易懂,适合所有用户使用。 首先,手册会详细介绍iad132的外观和主要功能。它会对每一个按钮、接口进行示意图和文字解释,方便用户快速掌握设备的外观和功能布局。 其次,手册会介绍断电启动、以太网连接、Wi-Fi设置等基本设置步骤。通过手册的指引,用户可以轻松完成iad132的初次设置,并与网络进行连接,为后续的使用打下基础。 除此之外,手册还会详细介绍iad132的高级功能,比如QoS配置、安全性设置、VPN网络建立等。通过手册的介绍,用户可以了解如何根据自己的需求进行配置,以提高网络的运行效率和安全性。 此外,手册还会列举常见问题及解决方法,以帮助用户在使用过程中遇到问题时能够及时解决。这其中包括网络连接问题、无线信号强度问题等,用户可以根据手册提供的解决方案进行操作,解决问题。 最后,手册还会附上iad132的技术规格和注意事项。技术规格会详细列出设备的硬件参数和性能指标,方便用户了解设备的性能和适用范围。注意事项则会提醒用户在使用过程中需要注意的事项,以避免不必要的损失和风险。 总之,华为iad132用户手册通过详细的介绍和操作指南,能够帮助用户快速掌握iad132设备的使用方法和配置技巧,为用户提供便捷的网络体验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值