The easiest way to add an iAD banner to your app
Today I'll show a very simple way to integrate an ad banner to your iOS app. Most tutorials (including mine) explain the complex version by implementing the ADBannerViewDelegate protocol. If you don't care about error handling, animations, positioning or the maximum number of allowed banner instances (10!): There is a much easier way which requires only two lines of code in SWIFT.
For details how to subscribe for the Apple iAds program, please check my previous article about iAD integration.
1. Create the sample project:
2. Ad the iAD framework to your project:
3. Add these two lines of code to your ViewController class:
import UIKit
import iAd
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.canDisplayBannerAds = true
}
}
That's all for today.
Cheers,
Stefan
Cheers,
Stefan
This comment has been removed by a blog administrator.
ReplyDelete