Собственная реклама на Facebook в iOS Swift - PullRequest
0 голосов
/ 02 мая 2019

Я пытался добавить нативную рекламу, используя сеть аудитории Facebook, в свое приложение iOS, используя язык Swift. Но объявление не загружается и приложение вылетает при регистрации.

var nativeAd: FBNativeAd!
    @IBOutlet weak var imgAdIcon: FBMediaView!
    @IBOutlet weak var lblAdBody: UILabel!
    @IBOutlet weak var lblAdTitle: UILabel!
    @IBOutlet weak var btnAdAction: UIButton!
    @IBOutlet weak var adsponsored: UILabel!
    @IBOutlet weak var adMediaView: FBMediaView!
    @IBOutlet weak var adOptionsView: FBAdChoicesView!
    @IBOutlet weak var adSocialContext: UILabel!
override func viewDidLoad()
    {
        super.viewDidLoad()    
        var nativeAd = FBNativeAd(placementID:"293******7578_29*******68")
        nativeAd.delegate = self
        nativeAd.loadAd()
}


func nativeAdDidLoad(_ nativeAd: FBNativeAd)
    {
        self.nativeAd = nativeAd
         showNativeAd()       
    }


func showNativeAd()
    {
        if (nativeAd != nil) && nativeAd.isAdValid
        {
            viewAdContainer.isHidden = false
            nativeAd.registerView(forInteraction: viewAdContainer, mediaView: adMediaView, iconView: self.imgAdIcon, viewController: self, clickableViews: [btnAdAction, adMediaView])

            // Render native ads onto UIView
            lblAdTitle.text = nativeAd.advertiserName
            lblAdBody.text = nativeAd.bodyText
            adSocialContext.text = nativeAd.socialContext
            adsponsored.text = nativeAd.sponsoredTranslation
            btnAdAction.setTitle(nativeAd.callToAction, for: .normal)
            adOptionsView.nativeAd = nativeAd
        }
    }

Я получил ошибку Error

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setNativeAdBase:]: unrecognized selector sent to instance 0x102f79040'
*** First throw call stack:
(0x183d5ad8c 0x182f145ec 0x183d68098 0x18de4ddb0 0x183d605c8 0x183c4641c 0x100d728e0 0x100d2b6c8 0x100d2aec4 0x100d2af1c 0x100d72fc4 0x100d78190 0x100d74638 0x100d9652c 0x102ac91dc 0x102ac919c 0x102acdd2c 0x183d03070 0x183d00bc8 0x183c20da8 0x185c06020 0x18dc40758 0x100d376c0 0x1836b1fc0)
libc++abi.dylib: terminating with uncaught exception of type NSException

...