Michael Reeve
Michael Reeve

Reputation: 23

How to toggle iAd visibility spritekit

I have this SpriteKit app where I want to have a add show up on the main menu, and when the player dies. I already have NSNotifiactions setup. I just want to know how to toggle the visibility of the iAd.

I have tried 3 things:

  1. Alpha - I was told this would work but it didn't:

    [banner setAlpha:0]

  2. "self.canDisplayBannerAds":

    self.canDisplayBannerAds=NO;

  3. Removing Banner from subview:

    [banner removeFromSuperview]

Sounds kinda weird right? If you know please write an answer!

Upvotes: 0

Views: 63

Answers (1)

user3955948
user3955948

Reputation:

for example

ViewController.m

@import <iAd>;

@interface ViewController () <GameSceneDelegate,ADBannerViewDelegate>

_bannerView = [[ADBannerView alloc] initWithAdType:ADAdTypeBanner];
_bannerView.frame = CGRectMake(0, self.view.frame.size.height - _bannerView.frame.size.height, self.view.frame.size.width, _bannerView.frame.size.height);
_bannerView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleWidth; 
_bannerView.delegate = self;
[self.view addSubview:_bannerView];

if you want to hide ad use this: _bannerView.hidden = YES;

Upvotes: 1

Related Questions