iAd banner position not updating

61 views Asked by At

I am currently adding iAd banners into my SpriteKit game, and I have successfully got the ads showing. But when I go to remove the banner by pushing it off the bottom it does not move, even though it is the exact opposite to the code to get it to appear.

This is the function, which is called from a notification observer:

func hideBannerAd(notification:NSNotification)
{
    if bannerAdVisible == true
    {
        println(bannerAd.frame);

        UIView.beginAnimations("hideAd", context: nil);
        bannerAd.frame = CGRectOffset(bannerAd.frame, 0, bannerAd.frame.size.height);
        println(bannerAd.frame);
        UIView.commitAnimations()
        bannerAdVisible = false
        bannerAd.cancelBannerViewAction()
    }
}

The 2 println statements produce the following:

(0.0, 1024.0, 768.0, 66.0)

(0.0, 1090.0, 768.0, 66.0)

So the position of the banner is being changed, but it is not shown on the screen.

If you know the problem, I would be grateful for a little help.

EDIT I will add that the hideBannerAd and all of the code to do with the ad is in the GamveViewController.

1

There are 1 answers

0
Antony On BEST ANSWER

Problem Solved!

With the assistance from @aramusss comment I have found that I was calling the function to show the banner in the viewWIllLayoutSubViews function, so I moved it to the viewDidLoad function and it now works!

Thank you all for your help!