2011-11-24 58 views
1

當我運行我的應用程序時,我收到iAd橫幅視圖的消息。這是什麼意思?iAds不能在模擬器和設備中工作

錯誤域= ADErrorDomain代碼= 3 「的操作無法完成 。廣告資源不可用」 的UserInfo = 0x60455a0 {ADInternalErrorCode = 3,NSLocalizedFailureReason =廣告庫存 不可用}

這是我的代碼:

#pragma mark - 
#pragma mark create BannerView: 
- (void)createAdBannerView { 
    Class classAdBannerView = NSClassFromString(@"ADBannerView"); 
    if (classAdBannerView != nil) { 
     self.adBannerView = [[[classAdBannerView alloc] initWithFrame:CGRectZero] autorelease]; 
     [adBannerView setRequiredContentSizeIdentifiers:[NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil]]; 
     if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) { 
      [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape]; 
     } else { 
      [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];    
     } 
     [adBannerView setFrame:CGRectOffset([adBannerView frame], 0, -[self getBannerHeight])]; 
     [adBannerView setDelegate:self]; 

     [self.view addSubview:adBannerView];   
    } 
} 

- (void)fixupAdView:(UIInterfaceOrientation)toInterfaceOrientation { 
    if (adBannerView != nil) {   
     if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { 
      [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape]; 
     } else { 
      [adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait]; 
     }   
     [UIView beginAnimations:@"fixupViews" context:nil]; 
     if (adBannerViewIsVisible) { 
      CGRect adBannerViewFrame = [adBannerView frame]; 
      adBannerViewFrame.origin.x = 0; 
      adBannerViewFrame.origin.y = 0; 
      [adBannerView setFrame:adBannerViewFrame]; 
      CGRect contentViewFrame = contentView.frame; 
      contentViewFrame.origin.y = [self getBannerHeight:toInterfaceOrientation]; 
      contentViewFrame.size.height = self.view.frame.size.height - [self getBannerHeight:toInterfaceOrientation]; 
      contentView.frame = contentViewFrame; 
     } else { 
      CGRect adBannerViewFrame = [adBannerView frame]; 
      adBannerViewFrame.origin.x = 0; 
      adBannerViewFrame.origin.y = -[self getBannerHeight:toInterfaceOrientation]; 
      [adBannerView setFrame:adBannerViewFrame]; 
      CGRect contentViewFrame = contentView.frame; 
      contentViewFrame.origin.y = 0; 
      contentViewFrame.size.height = self.view.frame.size.height; 
      contentView.frame = contentViewFrame;    
     } 
     [UIView commitAnimations]; 
    } 
} 





#pragma mark - 
#pragma mark ADBannerViewDelegate 

- (void)bannerViewDidLoadAd:(ADBannerView *)banner { 
    if (!adBannerViewIsVisible) {     
     adBannerViewIsVisible = YES; 
     [self fixupAdView:[UIDevice currentDevice].orientation]; 
    } 
} 

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error 
{ 
    NSLog(@"the failed error is %@",error); 
    if (adBannerViewIsVisible) 
    {   
     adBannerViewIsVisible = NO; 
     [self fixupAdView:[UIDevice currentDevice].orientation]; 
    } 
    //NSLog(@"bannerView:didFailToReceiveAdWithError: %@",[error localizedDescription]); 

} 


how to solve this problem 

回答

0

「廣告資源不可用」表示......沒有可用的廣告。它看起來好像工作正常。

iAd很容易實現,但它們的填充率很低(即許多請求未實現),而且在許多國家/地區根本不可用。

2

您將在模擬器或設備中隨機獲取此錯誤消息,以便您可以在沒有iAd可用時測試您的應用及其行爲(隱藏AdView,使用其他廣告提供商...)。但它不是來自Simulator/iAd框架/ iAd網絡的錯誤:這是一個更好的測試功能。

此外,在測試設備上以測試模式部署應用程序時,您無法獲得「真正的」iAds。它必須由Apple審覈並從AppStore下載。

0

從您的設備中刪除應用程序,然後從XCode重新安裝。這爲我修好了。

相關問題