// // ViewController.swift // KMAdvertisementDemo_iOS // // Created by lizhe on 2022/11/23. // import UIKit import KMAdvertisement_iOS class ViewController: UIViewController { @IBOutlet weak var advertisementView: KMAdvertisementShowView_iOS! @IBOutlet weak var showView: UIView! @IBOutlet weak var advertisementScroll: KMAdvertisementShowScroll_iOS! @IBOutlet weak var showScrollView: UIView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. // Do any additional setup after loading the view. //设置基础参数 KMAdvertisementManager.manager.initConfig(appName: .PDFReaderProIOS, subscribeType: .unsubscribed, platform: .iOS) //测试模式,默认false KMAdvertisementManager.manager.debug = true unowned let weakSelf = self //获取广告数据 KMAdvertisementManager.manager.fetchData { data, error in if data != nil { for model in data! { if model.showType == .scroll { //视图加载方法一 let view = KMAdvertisementManager.manager.show(type: .scroll, data: model, superView: weakSelf.showScrollView) { actionType, actionItem in print("点击了 scroll 1") } _: { data in print("数据刷新了") } // //视图加载方法二 // weakSelf.advertisementScroll.inputData = model // weakSelf.advertisementScroll.actionCompletion = { actionType, actionItem in // print("点击了 scroll 2") // } } if model.showType == .view { //视图加载方法一 let view = KMAdvertisementManager.manager.show(type: .view, data: model, superView: weakSelf.showView) { actionType, actionItem in print("点击了 view 1") } _: { data in print("数据刷新了") } //视图加载方法二 weakSelf.advertisementView.inputData = model weakSelf.advertisementView.actionCompletion = { actionType, actionItem in print("点击了 view 2") } } } } } } }