(Sprite Kit Game) I want my ad banners to be hidden during gameplay. I\'ve set up my project to contain both iAd and AdMob advertisement banners. Prior to adding in the AdMo
You could use a BOOL as a switch to show either appleAd or googleBanner, or none as you might want:
In your .h file:
BOOL isAppleAd;
BOOL isGoogleAd;
Then do something like this:
- (void)showsBanner {
if (isAppleAd == YES) {
[self appleAd];
}
if (isGoogleAd == YES) {
[self googleAd];
}
else {
[self hideBothBanners];
}
}
- (void)appleAd {
if (isAppleAd == YES) {
NSLog(@"Showing Apple Banner");
//googleAd OFF
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0];
[googleBanner_ setAlpha:0];
[UIView commitAnimations];
// iAd ON
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[appleAd setAlpha:1.0];
[UIView commitAnimations];
// switch off AppleAd to use as switch
isAppleAd = NO;
isGoogleAd = YES;
} else {
// do something else
return;
}
}
- (void)googleAd {
if (isGoogleAd == YES) {
NSLog(@"Showing Google Banner");
// iAd OFF
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0];
[appleAd setAlpha:0];
[UIView commitAnimations];
// googleAd ON
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[googleBanner_ setAlpha:1.0];
[UIView commitAnimations];
// switch off GoogleAd to use as switch
isGoogleAd = NO;
isAppleAd = YES;
} else {
// do something else
return;
}
}
- (void)hideBothBanners {
NSLog(@"Hiding Both Banners");
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0];
[appleAd setAlpha:0];
[googleBanner_ setAlpha:0]
[UIView commitAnimations];
}