2. In "Targets," select iad_swift_universal. At top select the "General" tab. Select "Linked Frameworks and Libraries" and add the iAd framework.
3. Select the storyboard and unselect "Use Auto Layout."
4. Drag an iAd BannerView to the storyboard.
5. Control-drag the ADBannerView to the ViewController. Select "delegate" as the outlet.
6. Complete the code as below:
import UIKit
import iAd
class ViewController: UIViewController, ADBannerViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
func bannerViewDidLoadAd(banner: ADBannerView!) {
}
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
return true
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
}
No comments:
Post a Comment