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;
}
}
任何幫助,將不勝感激。
但爲什麼在同一時間它在iPhone上工作,但在iPad2上發生錯誤。 – 2012-03-14 11:28:03
因爲當iPad的廣告請求沒有庫存。 – 2012-03-14 11:31:16
這是一個設備(iPhone 4)工作正常,但在其他設備(3GS)根本行不通。它總是發生。我測試了很多應用程序。 – 2012-05-18 11:37:19