ios - iAd interstitial Service session terminated -


im building test app show iad interstitial, have implement manually view. i've done after presenting iad interstitial sometime closes , gives me : service session terminated.

here code :

 var interad = adinterstitialad()     var interadview: uiview = uiview()      var closebutton = uibutton(type: uibuttontype.system) uibutton      override func viewdidload() {         super.viewdidload()         // additional setup after loading view, typically nib.          closebutton.frame = cgrectmake(10, 13, 20, 20)         closebutton.layer.cornerradius = closebutton.frame.size.width / 2         closebutton.clipstobounds = true         closebutton.settitle("x", forstate: .normal)         closebutton.contentverticalalignment = uicontrolcontentverticalalignment.top         closebutton.settitlecolor(uicolor(red: 109/255, green: 109/255, blue: 109/255, alpha: 1), forstate: .normal)         closebutton.backgroundcolor = uicolor.whitecolor()         closebutton.layer.bordercolor = uicolor(red: 109/255, green: 109/255, blue: 109/255, alpha: 1).cgcolor         closebutton.layer.borderwidth = 2         closebutton.addtarget(self, action: "close:", forcontrolevents: uicontrolevents.touchdown)       }      func close(sender: uibutton) {         closebutton.removefromsuperview()         interadview.removefromsuperview()     }      @ibaction func showad(sender: uibutton) {         loadad()     }      func loadad() {         print("load ad")         interad = adinterstitialad()         interad.delegate = self     }      func interstitialaddidload(interstitialad: adinterstitialad!) {         print("ad did load")          interadview = uiview()         interadview.frame = self.view.bounds         super.view.addsubview(interadview)          interadview.layer.transform = catransform3dmaketranslation(0, 500, 0)         uiview.animatewithduration(0.4, animations: {             self.interadview.layer.transform = catransform3dmaketranslation(0,0,0)             self.interad.presentinview(self.interadview)             uiviewcontroller.prepareinterstitialads()             self.interadview.addsubview(self.closebutton)          })      }      func interstitialaddidunload(interstitialad: adinterstitialad!) {      }      func interstitialad(interstitialad: adinterstitialad!, didfailwitherror error: nserror!) {         print("failed receive")         print(error.localizeddescription)          closebutton.removefromsuperview()         interadview.removefromsuperview()      } 

and thing interstitial should presented on status bar shows status bar while presented :

should that: http://i.stack.imgur.com/vatvk.png

but coming me : http://i.stack.imgur.com/f0p2t.png

discuss first issue , think have interstitialad wrong place. try set below viewdidload() method, inshort need addsubview superview. this.

override func viewdidload()  { super.viewdidload() super.view.addsubview(interadview)  //write other stuff 

discussing second issue, need manualy hide statusbar while adinterstitialad present. in interstitialad's delegate method. not familiar swift launguage can understand think need hide interstitial in method.

 private func loadinterstitial() {  //statusbar hide 

and need again show

  func interstitialdiddismissscreen (interstitial: gadinterstitial) {    //show statusbar 

note:- here link hide , show statusbar in swift.

how hide ios 7 status bar


Comments