共享横幅iAd / admob,调解无效

时间:2015-03-08 20:06:35

标签: ios admob iad mediator

无法让iAd / AdMob进行调解。我有2个VC共享横幅。但是,两个横幅同时加载,并忽略bannerViewDidLoadAd和didFailToReceiveAdWithError。为什么我不能让广告进行调解?

我将BELOW代码放在两个视图控制器

-(AppDelegate *)appdelegate{
return (AppDelegate *) [[UIApplication sharedApplication] delegate];
}


-(void)viewWillAppear:(BOOL)animated{

//iAD

_iAdView= [[self appdelegate] iAdView];
_iAdView.delegate=self;

screenBounds = [[UIScreen mainScreen] bounds];

[_iAdView setFrame:CGRectMake(0, 0, _iAdView.bounds.size.width,  _iAdView.bounds.size.height)];

_iAdView.center = CGPointMake(screenBounds.size.width / 2,  screenBounds.origin.y + (_iAdView.bounds.size.height / 2));

[self.view addSubview:_iAdView];



//ADMOB

_adMobView= [[self appdelegate] adMobView];

    _adMobView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];

_adMobView.adUnitID =  @"My-Unit-ID";

_adMobView.rootViewController = self;

GADRequest *request =[GADRequest request];

request.testDevices = @[ @"Test-Number" ];

[_adMobView loadRequest:request];

[_adMobView setFrame:CGRectMake(0, 0, _adMobView.bounds.size.width, _adMobView.bounds.size.height)];

_adMobView.center = CGPointMake(screenBounds.size.width / 2, screenBounds.size.height - (_adMobView.bounds.size.height / 2)); 

[self.view addSubview:_adMobView];

}


 -(void)viewWillDisappear:(BOOL)animated{

//iAD

_iAdView.delegate = nil;
_iAdView=nil;

_iAdView.alpha=0.0; 


//ADMOB

_adMobView.delegate=nil;
_adMobView=nil;

_adMobView.alpha=0.0;
 }


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

NSLog(@"iAd received");

_iAdView.alpha=1.0;
_adMobView.alpha = 0.0;

[UIView commitAnimations];
  }


 -(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{

NSLog(@"iAd failed, AdMob received");

_iAdView.alpha=0.0;
_adMobView.alpha=1.0;

[UIView commitAnimations];
}

0 个答案:

没有答案