Subview displays behind everything, after having put an adbannerview

| | August 10, 2015

I have a main View and a subView.
Everything worked perfectly: I click on a button “Open” on the View, that displays the subView above everything, and I can close the subView.

I decided to add an adBannerView at the bottom of my app.
When I run the app, the adbannerView works perfectly: the add is loaded into a frame at the bottom of my App.
But when I click on the button “Open”, the subView doesn’t display above everything anymore.
It displays UNDER everything on the View.
Can you help me solve this issue? Thank you so much!

Here is the code I’ve implemented for the adBannerView and the subView (I have removed other code not relevant for my problem):

import UIKit
import iAd

class ViewController: UIViewController, ADBannerViewDelegate {

@IBOutlet weak var boutonChangerPays: UIButton!
@IBOutlet weak var cadrePays: UIView! 
@IBOutlet weak var bannierePub: ADBannerView!

// Chargement initial de la Vue principale
override func viewDidLoad() {

    super.viewDidLoad()

    // Cadre Pays
    self.cadrePays.hidden = true

    // Banniere Ad
    self.canDisplayBannerAds = true
    self.bannierePub.delegate = self
    self.bannierePub.hidden = true
}

//*************************
// ADBANNERVIEW
// BANNIERE  DE  PUBLICITE
func bannerViewWillLoadAd(banner: ADBannerView!) {
    NSLog("bannierePub se charge")
}

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

func bannerViewActionDidFinish(banner: ADBannerView!) {
    NSLog("bannierePub a finit de se charger")
}

func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
    NSLog("Action pendant que la bannière se charge")

    return true
}

//**************************************************************************
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

// Retour de l'écran de détail
override func viewDidAppear(animated: Bool) {
    // Indicateur d'Activité : caché
    self.indicateurActivite.stopAnimating()
    self.indicateurActivite.hidden = true
}

// Bouton Changer Pays
@IBAction func boutonChangerPays(sender: UIButton) {

    // On affiche la Vue des Pays
    self.cadrePays.hidden = false
}       
}

One Response to “Subview displays behind everything, after having put an adbannerview”

  1. You can call this function to bring subview above everything.

    self.view.bringSubviewToFront(self.yourSubviewName)
    

Leave a Reply