gpt4 book ai didi

ios - 控制台中显示的 ADBannerView 未处理错误

转载 作者:可可西里 更新时间:2023-11-01 03:19:47 26 4
gpt4 key购买 nike

我按照苹果开发指南文档以编程方式在我的 iOS 应用程序上添加 iAd。虽然我在 stackoverflow 上搜索了以前的解决方案,但不幸的是它们似乎都没有帮助我。这是以下错误:

iAdBanner failed [AppDeveloper] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=7 "The operation couldn’t be completed. Ad was unloaded from this banner" UserInfo=0xb07b9a0 {ADInternalErrorCode=7, ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=Ad was unloaded from this banner}. One thing worth mentioning that most of the time I get the message that iAdBanner loaded. here is the following code of my project SinglePlayerViewController.h

代码如下

 #import <iAd/iAd.h>
@interface SinglePlayerViewController : UIViewController <ADBannerViewDelegate>

{
ADBannerView *adView;
}

SinglePlaerViewController.m代码:

    - (void)viewDidLoad
{
[super viewDidLoad];

adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
CGRect adFrame = adView.frame;
adFrame.origin.y = self.view.frame.size.height-adView.frame.size.height;
adView.frame = adFrame;
adView.delegate =self;
[self.view addSubview:adView];
}
-(void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"iAdBanner failed");
}
-(void) bannerViewDidLoadAd:(ADBannerView *)banner
{

NSLog(@"iAdBanner loaded");
}

最佳答案

只需尝试以下操作:

@interface SinglePlayerViewController : UIViewController<ADBannerViewDelegate>

@property (nonatomic, retain) ADBannerView *adView;

@end

- (void)viewDidLoad
{
[super viewDidLoad];

self.adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
self.adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
CGRect adFrame = self.adView.frame;
adFrame.origin.y = self.view.frame.size.height-self.adView.frame.size.height;
self.adView.frame = adFrame;
self.adView.delegate =self;
[self.view addSubview:self.adView];
}

HTH

关于ios - 控制台中显示的 ADBannerView 未处理错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19498467/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com