iAd横幅在模拟器上显示测试广告,但在设备上没有 [英] iAd banner shows test ad on simulator but not on device

查看:259
本文介绍了iAd横幅在模拟器上显示测试广告,但在设备上没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的iPhone应用程序上放置一个iAd横幅。这是我宣布横幅广告的地方:

I am trying to put an iAd banner on my iPhone app. Here is where I declare the banner ad:

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDuration:1];

    [banner setAlpha:1];

    [UIView commitAnimations];
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDuration:1];

    [banner setAlpha:0];

    [UIView commitAnimations];
}

当我在模拟器上测试时,测试广告会立即显示出来。当我在我的设备上测试时,没有任何显示。

When I test on the simulator, the test ad shows up straight away. When I test on my device, nothing shows up.

我最近注册了Apple的iAd系统,但是当我尝试查看iTunes Connect的iAd部分时,它告诉我,iAd网络目前无法使用。这就是为什么测试广告不会出现在我的设备上?如果是这样,为什么它仍然出现在模拟器上?

I have recently registered with Apple's iAd system, but when I try look look at the iAd section of iTunes Connect, it tells me that the iAd network is currently unavailable. Is this why the test ad won't show up on my device? If so, why is it still showing up on the simulator?

推荐答案

我希望这可以对新用户有所帮助,这是有效的对我来说:

I hope this can be helpful to new users, this works for me:

在ViewController.h中

In ViewController.h

  @interface ViewController : UIViewController <ADBannerViewDelegate> {    
  }
  @property (nonatomic, strong) ADBannerView *banner;
  @end

在ViewController中

And in ViewController

- (void)viewDidLoad{
  [super viewDidLoad];
  //self.canDisplayBannerAds = YES; This give me a error    
  self.banner = [[ADBannerView alloc] initWithFrame:CGRectZero];
  self.banner.delegate = self;
  [self.banner sizeToFit];
  self.banner.hidden = true;
}

最后一件事:

实现两种方法:

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
if (banner.isBannerLoaded) {
    [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
    // Assumes the banner view is placed at the bottom of the screen.
    banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
    [UIView commitAnimations];
 }
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner{
 NSLog(@"Showing iAd");
 self.banner.hidden = false;
 ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0,    self.view.frame.size.height - 50, 320, 50)];
  //adView.delegate = self;
 [self.view addSubview:adView];
}

这篇关于iAd横幅在模拟器上显示测试广告,但在设备上没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆