ios - iAd 错误但广告似乎显示正常

标签 ios iad

我在 View Controller 的底部加载横幅广告,它们加载连接到 iAd 网络的添加消息

但在 xcode 屏幕底部收到错误消息

2014-07-20 11:21:38.515 WeddingsAndMore[30983:60b] Reachability Flag Status: -R ------- networkStatusForFlags
2014-07-20 11:21:38.768 WeddingsAndMore[30983:60b] Error receive ad: Error Domain=ADErrorDomain Code=7 "The operation couldn’t be completed. Ad was unloaded from this banner" UserInfo=0x10db25db0 {ADInternalErrorCode=7, NSLocalizedFailureReason=Ad was unloaded from this banner, ADInternalErrorDomain=ADErrorDomain}
2014-07-20 11:21:38.971 WeddingsAndMore[30983:60b] [AppDeveloper] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=3 "The operation couldn’t be completed. Ad inventory unavailable" UserInfo=0x10d87e570 {ADInternalErrorCode=3, NSLocalizedFailureReason=Ad inventory unavailable, ADInternalErrorDomain=ADErrorDomain}
2014-07-20 11:21:39.972 WeddingsAndMore[30983:60b] [AppDeveloper] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=5 "The operation couldn’t be completed. Banner view is visible but does not have content" UserInfo=0x10d9272b0 {ADInternalErrorCode=5, NSLocalizedFailureReason=Banner view is visible but does not have content, ADInternalErrorDomain=ADErrorDomain}

我在模拟器中打开它的时间越长,我得到的就越多

代码如下

.h文件

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>

@interface DMKPickViewController : UIViewController <ADBannerViewDelegate>
@property (strong, nonatomic) IBOutlet ADBannerView *bannerView;

@end

.m文件

#import "DMKPickViewController.h"

#import "DMKAppDelegate.h"

@interface DMKPickViewController ()

@end

@implementation DMKPickViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}







- (void)viewDidLoad
{

    _bannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
    _bannerView.delegate = self;
    _bannerView.hidden = NO;

    [self.view addSubview:_bannerView];
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    NSLog(@"bannerViewDidLoadAd");
    CGRect bannerFrame = CGRectMake(0.0, (self.view.frame.size.height - 50), 0.0, 0.0);
    [self.bannerView setFrame:bannerFrame];
    self.bannerView.hidden = NO;
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"Error receive ad: %@", error);
    self.bannerView.hidden = YES;
}

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner
               willLeaveApplication:(BOOL)willLeave
{
    return YES;
}

- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{

}






- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)viewDidAppear:(BOOL)animated
{

}

这是我第一次实现 iAd,所以我对此很陌生

最佳答案

如果您移动到无法看到广告的屏幕,建议您停用该广告。那么你应该没有任何接收不到的可能。从父 View 中删除它,将委托(delegate)设置为 nil,然后释放它。当它再次可见时再次创建它。

关于ios - iAd 错误但广告似乎显示正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24849589/

相关文章:

ios - UICollectionView allowsMultipleSelections 不工作

iphone - 如何使用 Core Graphics 绘制弧线以及如何旋转该弧线

ios - 是否允许隐藏 iAds,即使它们可用?

ios - 如何以编程方式在 iOS 的 iAds 横幅上显示广告

ios - 我怎么知道我的 ipAd 在应用程序发布后可以正常工作?

ios - Swift:iAd UITableViewController 位置

ios - DidSelect 注解被调用

ios - 向 popToRootViewController 添加自定义动画

ios - 可以在后台线程上从 ASIHTTPRequest/AFNetworking 执行 completionBlock 吗?

ios - 当用户与 iAd Swift 交互时暂停游戏