Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

FunFact App: Unable to change background colour when using iAd.

When adding iAd's to the randomFacts app it causes the background colour unable to change when pressing the button. The facts still randomly display but the colour doesn't change.

Something about this

     self.canDisplayBannerAds = true
     self.adBannerView!.delegate = self
     self.adBannerView?.hidden = true

makes this not work:

  @IBAction func tapRandomQuote(sender: AnyObject) {
      var randomColor = colorWheel.randomColor()
      view.backgroundColor = randomColor
   }

I know I am not the only persona having this issues, but does anyone have any ideas why this may be happening ?

Here is the full code;

override func viewDidLoad() {
    super.viewDidLoad()

    self.canDisplayBannerAds = true
    self.adBannerView!.delegate = self
    self.adBannerView?.hidden = true

    }

@IBAction func tapRandomQuote(sender: AnyObject) {
    var randomColor = colorWheel.randomColor()
    view.backgroundColor = randomColor
}

    func bannerViewDidLoadAd(banner: ADBannerView!) {
    self.adBannerView!.hidden = false
   }

func bannerViewActionShouldBegin(banner:   ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool     {
    return true
}


}

1 Answer

Sorry Jas,

It's been a long time since I've work on an iOS app. I'll let you know it I find an answer.

Kevin

It's ok thanks for replying (Y) I managed to find the answer.

Needed to change "view.backgroundcolor" to "originalContentView.backgroundcolor"