I added the iAd framework
. I drag and dropped the iAdBannerView
onto the view controller. Then I set constraints for the banner. Next I connected the banner to the ViewController.swift
file. After doing so I wrote this code :-
On top of file :
import iAd
class ViewController: UIViewController, UITextFieldDelegate, ADBannerViewDelegate
{
Creating the outlet :
@IBOutlet var adBannerView: ADBannerView!
In viewDidLoad() :
self.canDisplayBannerAds = true
self.adBannerView.delegate = self
self.adBannerView.hidden = true
Next I created these two functions :
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
return true
}
func bannerViewDidLoadAd(banner: ADBannerView!) {
adBannerView.hidden = false
}
This is all I did. I didn't fill any form on iTunes connect or import any other framework related to iAds. This is literally all that I have done.
But yet when I ran the app on the simulator, the iAd banner did not show up. It did not even show the Ads by Apple. Nothing at all. It just blended in with the app. I ran the app on my phone, and still nothing. I uploaded the app to the AppStore, and I still don't see anything when I download my app from the AppStore. Any idea what went wrong here? Thanks in advance :)