iAD仅适用于某些设备

时间:2012-03-14 11:12:10

标签: objective-c

iAd在配备iOS 4.3.1的iPhone 3GS和配备iOS 4.3.1的iPhone 4上运行良好但在具有iOS 5.0.1的iPad 2上无效。

我正在接受以下错误。

错误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;
}   
  }


任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

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

这不是代码中的问题,而是Apple没有足够的广告投放。他们的填充率非常低,所以你必须迎合没有广告的情况。许多人使用AdWhirl等服务来回退到其他广告网络甚至展示“住宅”广告。