2012-03-14 107 views
1

的iAd是在iPhone 3GS做工精細有iOS的5.0.1和iPhone 4的iOS爲4.3.1工作,但它並沒有在iPad 2有工作的iOS 5.0.1。的iAD僅在某些設備上

我收到follwoing錯誤。

錯誤域= ADErrorDomain代碼= 3 「的操作couldn \ u2019t完成的廣告資源不可用」。的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; 
} 
    } 


任何幫助,將不勝感激。

回答

0

答案是錯誤消息給出:廣告資源不可用。

這不是代碼中的問題,而是Apple沒有足夠的廣告來投放。他們的填充率非常低,所以你必須迎合沒有廣告可用的情況。許多人使用的服務,如AdWhirl廣告回落到其他廣告網絡,甚至顯示爲「房子」的廣告。

+0

但爲什麼在同一時間它在iPhone上工作,但在iPad2上發生錯誤。 – 2012-03-14 11:28:03

+0

因爲當iPad的廣告請求沒有庫存。 – 2012-03-14 11:31:16

+0

這是一個設備(iPhone 4)工作正常,但在其他設備(3GS)根本行不通。它總是發生。我測試了很多應用程序。 – 2012-05-18 11:37:19

相關問題