0

In my ViewController, when I set

self.canDisplayBannerAds = YES; 

the banner ad resizes my SKScene to fit the iAd view in at the bottom of the screen. This causes things to shift around and be displayed differently (parts of my background are cut out of view). How can I make the ad show on top of my view rather than resizing my entire view?

Also, how do I change my ViewController's 'canDisplayBannerAds' property from an SKScene, so that it only shows at appropriate times?

1 Answers1

0

I'm not sure about the first part of your question, Changing iAd position and placement I think if you fiddle around with what this guy's solution you'll be able to get it down.

As for the second part I think your best choice for changing the canDisplayBannerAds bool in SKScene would be using the NSNotificationCenter, these two prompts would be in your viewDidLoad method

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(showsBanner)
                                             name:@"showsBanner"
                                           object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(hidesBanner)
                                             name:@"hidesBanner"
                                           object:nil];

the @selector part of this code would then call these methods which would be placed into your viewController as well

-(void)hidesBanner {
     [_adView setAlpha:0];
     self.bannerIsVisible = NO;
}

-(void)showsBanner {
     [_adView setAlpha:1];
     self.bannerIsVisible = YES;
}

and finally whenever you wanted to use either of the methods in any of your SKScenes you would write this line

[[NSNotificationCenter defaultCenter]postNotificationName:@"hidesBanner" object:self];
        //above line calls hidesBanner, @"showsBanner" would call showsBanner
Community
  • 1
  • 1