ios - Hiding iAd ADBannerView in Swift when ad fails to load - no delegate or delegate does not implement didFailToReceiveAdWithError -
this code using:
var bannerview = adbannerview() self.candisplaybannerads = true //show ad banner if ad loads func bannerviewdidloadad(banner: adbannerview!) {bannerview.hidden = false} //hide ad banner if ad fails load func bannerviewfailstoloadad(banner: adbannerview!,didfailtoreceiveadwitherror error: nserror!) {bannerview.hidden = true println("failed receive ad")}
when set iad fill rate 0% nothing printed , output console:
adbannerview: unhandled error (no delegate or delegate not implement didfailtoreceiveadwitherror:): error domain=aderrordomain code=5 "the operation couldn’t completed. banner view visible not have content" userinfo=0x7fd3fd3335e0 {adinternalerrorcode=5, nslocalizedfailurereason=banner view visible not have content, adinternalerrordomain=aderrordomain}
delegate methods not called when using self.candisplaybannerads = true
. need create adbannerview
, set delegate
delegate methods called, example, bannerview.delegate = self
.
self.candisplaybannerads = true
no hassle way of implementing iad banners. create adbannerview
you, display if receives ad, , hide if not receive ad. there no need implement delegate methods when implementing iad banner in way.
so have 2 options, remove var bannerview = adbannerview()
, use iad banner self.candisplaybannerads = true
provides, or remove self.candisplaybannerads = true
, finish implementing own adbannerview
.
if decide implement own adbannerview
check answer here, ignore admob implementation.
Comments
Post a Comment