【问题标题】:Shared iAd banner unloads ad after dismissing navigation popover关闭导航弹出框后,共享 iAd 横幅会卸载广告
【发布时间】:2015-05-11 17:09:09
【问题描述】:

我看到了一些其他类似的问题,但可以找到任何答案...我有一个共享的 iAd 横幅。问题是当我将它加载到带有 TableViewController 的模态显示 NavigationController 中时,当我关闭 TableViewController 时,MainViewController 中的广告横幅会丢失广告,并且我收到以下错误:

ADBannerView:未处理的错误(没有委托或委托未实现 didFailToReceiveAdWithError:):错误域=ADErrorDomain Code=7“操作无法完成。广告已从此横幅中卸载”UserInfo=0x5b60e283649 {ADInternalErrorCode=7, NSLocalizedFailureReason=广告已从此横幅中卸载,ADInternalErrorDomain=ADErrorDomain}

视图设置我们是这样的: MainViewController --> NavigationController --> TableViewController

在应用程序的另一点,我以模态方式展示了一个带有共享广告的 ViewController,但我没有遇到这个问题。 (MainViewController --> ViewController)

这是来自 TableViewController 的代码:

.h

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

@interface TableViewController : UITableViewController <ADBannerViewDelegate>

@property (strong, nonatomic) IBOutlet UITableView *table;
@property (strong, nonatomic) ADBannerView *adView;

@end

.m

-(void) viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];
    // Insert Ad Bar
    AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication ]delegate];
    _adView = [appdelegate adView];
    _adView.delegate = self;
    self.canDisplayBannerAds = true;

    if (IPAD) {
        [_adView setFrame:CGRectMake(0, self.view.frame.size.height - 65, 320, 65)];
    }
    else {
        [_adView setFrame:CGRectMake(0, self.view.frame.size.height - 50, 320, 50)];
    }
    if (!_adView.bannerLoaded) {
        [_adView setAlpha:0];
    }
    [self.view addSubview:_adView];
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [banner setAlpha:1];
    [UIView commitAnimations];
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [banner setAlpha:0];
    [UIView commitAnimations];
}

任何提示将不胜感激。 谢谢

【问题讨论】:

  • 所以我在 TableViewController 之后为选定的单元格添加了一个 ViewController,并且 ViewController 上的共享广告横幅也丢失了广告。似乎当我离开这个 TableViewController 时,我得到了那个错误。我没有正确设置委托吗?
  • 所以当我返回 MainViewController 时 didFailToReceiveAdWithError 仍然运行,即使没有加载广告...

标签: ios objective-c uiviewcontroller uinavigationcontroller iad


【解决方案1】:

问题是因为我使用的是:

self.canDisplayBannerAds = true;

还有:

if (IPAD) {
    [_adView setFrame:CGRectMake(0, self.view.frame.size.height - 65, 320, 65)];
}
else {
    [_adView setFrame:CGRectMake(0, self.view.frame.size.height - 50, 320, 50)];
}
if (!_adView.bannerLoaded) {
    [_adView setAlpha:0];
}
[self.view addSubview:_adView];

因此创建了 2 个广告栏实例。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-09
    • 1970-01-01
    相关资源
    最近更新 更多