【问题标题】:iAD Working only on Some DevicesiAD 仅在某些设备上工作
【发布时间】:2012-03-14 11:12:09
【问题描述】:

iAd 在装有 iOS 5.0.1 的 iPhone 3GS 和装有 iOS 4.3.1 的 iPhone 4 上运行良好,但在装有 iOS 5.0.1 的 iPad 2 上却无法运行。

我收到以下错误。

Error Domain=ADErrorDomain Code=3 "操作无法完成。广告资源不可用" UserInfo=0x118ca00 {ADInternalErrorCode=3, NSLocalizedFailureReason=广告资源不可用}

以下是代码:-

- (void)createAdView {
    Class cls = NSClassFromString(@"ADBannerView");
    if (cls) {
        adView = [[cls alloc] initWithFrame:CGRectZero];

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

    // Set the current size based on device orientation
    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    adView.delegate = self;

    adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin;

    // Set intital frame to be offscreen
    CGRect adFrame = adView.frame;
    adFrame.origin.y = -44;
    adView.frame = adFrame;
    [UIView beginAnimations:@"showBanner" context:NULL];
    [self.view addSubview:adView];
    [UIView commitAnimations];
}
}

   //Hides iAd Banner
 - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error  {
if (bannerIsVisible){
    [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
    adView.frame = CGRectOffset(adView.frame, 0, -44);  // Move above screen
    [UIView commitAnimations];
    bannerIsVisible = NO;
}
}

   //Shows iAd Banner.
  - (void)bannerViewDidLoadAd:(ADBannerView *)banner {
if (!bannerIsVisible)   {
    [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
    adView.frame = CGRectOffset(adView.frame, 0, +44);  // Show on top of screen
    [UIView commitAnimations];
    bannerIsVisible = YES;
}   
  }


任何帮助将不胜感激。

【问题讨论】:

    标签: objective-c


    【解决方案1】:

    答案在给出的错误消息中:广告资源不可用。

    这不是您的代码有问题,而是 Apple 没有足够的广告来投放。他们的填充率非常低,因此您必须满足没有广告可用的情况。许多人使用 AdWhirl 等服务退回到其他广告网络,甚至展示“自家”广告。

    【讨论】:

    • 但是为什么它同时在 iPhone 上工作,但在 iPad2 上却报错。
    • 因为 iPad 请求广告时没有库存。
    • 它在一台设备(iPhone 4)上运行良好,但在其他设备(3gs)上无法运行。它总是发生。我测试了很多应用程序。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-08
    • 1970-01-01
    • 2013-10-08
    • 2011-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多