iphone - amazon ads for swift not working in ios -
i trying implement amazon ads ios using swift.the code provided amazon in objective c , have tried mirroring swift failed so.the following methods "adviewdidload" , "adviewdidfailtoload" working in objective c have stopped working in swift,but function "viewcontrollerforpresentingmodalview" working across both languages.here snippet of code
@iboutlet weak var amazonadview: amazonadview!
override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. var option1 = amazonadoptions() option1.istestrequest = false amazonadview.delegate = self self.amazonadview.loadad(option1) } func viewcontrollerforpresentingmodalview() -> uiviewcontroller { println("........here.......") return self; } func adviewdidload(view : amazonadview) { println("........here.1......") nslog("successfully loaded ad"); } // @optional func adviewdidfailtoload(view :amazonadview , witherror: amazonaderror ) { nslog("ad failed load. error code ") }
thanks
i've been having similar struggles , confused whether amazon, or me. implemented follows , ad appears sometimes, i'm not sure causes not appear @ times, , not trip delegate functions should when fails. had working setup several days, , flipped flag production, never showed again. i'm not sure if has it.
func setupamazonad(){ if(testamazonad != nil){ testamazonad?.removefromsuperview() } testamazonad = amazonadview(adsize: amazonadsize_320x50) var adoptions = amazonadoptions() // during development, must tell framework // app not production version adoptions.istestrequest = true testamazonad!.delegate = self self.view.addsubview(self.testamazonad!) self.view.bringsubviewtofront(self.testamazonad!) } func viewcontrollerforpresentingmodalview() -> uiviewcontroller! { return self } func adviewwillexpand(view: amazonadview!) { println("will present modal view ad. time pause other activities.") } func adviewdidcollapse(view: amazonadview!) { println("modal view has been dismissed, time resume paused activities.") } func adviewdidload(view: amazonadview!) { println("successfully loaded ad") } func adviewdidfailtoload(view: amazonadview, error:amazonaderror){ println("failed load") }
Comments
Post a Comment