8

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

iAdBanner failed [AppDeveloper] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=7 "The operation could not be done. Ad was unloaded from this banner" UserInfo=0xb07b9a0 {ADInternalErrorCode= 7、ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=广告已从此横幅中卸载}。值得一提的是,大多数时候我都会收到 iAdBanner 加载的消息。这是我的项目 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"); 
}
4

1 回答 1

1

只需尝试以下操作:

@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];
}    

高温高压

于 2014-02-13T16:23:55.070 回答