[cocos2dx 3.0 + ios]如何编写iAd的plugin(3)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-20 18:26 点击:次
p>}
p>
p>- (NSString*) getSDKVersion
p>{
p> return @"6.4.2";
p>}
p>
p>- (NSString*) getPluginVersion
p>{
p> return @"0.2.0";
p>}
p>
p>// 显示广告栏
p>- (void) showBanner: (int) pos
p>{
p> // 如果存在先删除,重新创建
p> if (nil != self.bannerView) {
p> [self.bannerView removeFromSuperview];
p> [self.bannerView release];
p> self.bannerView = nil;
p> }
p>
p> // 创建
p> self.bannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
p> self.bannerView.frame = CGRectOffset( self.bannerView.frame, 0, -50 );
p> self.bannerView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
p> self.bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
p> self.bannerView.delegate=self;
p> [AdsWrapper addAdView:self.bannerView atPos:pos];
p> self.bannerView.center = OUT_POS;
p> self.bannerPos = pos;
p> [UIView commitAnimations];
p> self.bannerVisible = false;
p>}
p>
p>// 在加载广告前通告
p>- (void)bannerViewWillLoadAd:(ADBannerView *)banner NS_AVAILABLE_IOS(5_0)
p>{
p> NSLog( @"bannerViewWillLoadAd" );
p>}
p>
p>// 每次有新广告加载后通告
p>- (void)bannerViewDidLoadAd:(ADBannerView *)banner
p>{
p> NSLog( @"bannerViewDidLoadAd" );
p> if( self.bannerVisible == false ) {
p> [self.bannerView removeFromSuperview];
p> [AdsWrapper addAdView:self.bannerView atPos:self.bannerPos];
p> [UIView commitAnimations];
p> self.bannerVisible = true;
p> // 向监听器发送广告显示的通告
p> [AdsWrapper onAdsResult:self withRet:kAdsShown withMsg:@"ok"];
p> }
p> // 向监听器发送接到数据的通告
p> [AdsWrapper onAdsResult:self withRet:kAdsReceived withMsg:@"ok"];
p>}
p>
p>// 发生错误
p>- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
p>{
p> NSLog( @"didFailToReceiveAdWithError" );
p> if( self.bannerVisible ) {
p> self.bannerView.center = OUT_POS;
p> self.bannerVisible = false;
p> // 向监听器发送广告隐藏(错过)的通告
p> [AdsWrapper onAdsResult:self withRet:kAdsDismissed withMsg:@"ok"];
p> }
p> // 向监听器发送广告接受数据错误的通告
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>