-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0];
[iAdBanner setAlpha:1];
iAdBanner.hidden=NO;
[UIView commitAnimations];
[self.iAdBanner setDelegate:self];
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0];
[iAdBanner setAlpha:0];
iAdBanner.hidden=YES;
[UIView commitAnimations];
bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
bannerView=[[GADBannerView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
self.bannerView.adUnitID=@"Unit-ID";
self.bannerView.rootViewController=self;
[self.view addSubview:self.bannerView];
GADRequest *request =[GADRequest request];
request.testDevices= @[ GAD_SIMULATOR_ID ];
[self.bannerView loadRequest:request];
}
The code inside BannerViewDidLoadAD method has a AdBannerView that's added into storyboard using Object Library in Xcode.
The code inside didFailToReceiveAdWithError is for making AdMob banner appear when iAd is hidden. But the AdMob banner doesn't respond to .hidden=YES/NO statements from Xcode.
This iAd/AdMob mediation solution only works in a ViewDidLoad statement, as soon as an app loads. I need the mediation to work in other methods like my -(void)GameOver method.
How can I place the code of the DidFailToReceiveAdWithError method inside the -(void)GameOver method so mediation would work and the programmatically added code would pay attention to .hidden=YES/NO statements?
Aucun commentaire:
Enregistrer un commentaire