update xcode 6 to 7 (code doesn't work swift) -


i have project swift webview ( i'm using wkwebview ) , worked without probles. made update of xcode 7.1 version , none of webview work. have no error have nothing in screen. if has idea thanks

(sorry english)

 class actu: uiviewcontroller, wknavigationdelegate  {  /**** variable declaration , iboutlet *****/      @iboutlet weak var contact: uibarbuttonitem!     var backbuttonitem:uibarbuttonitem!     var rightplaybarbuttonitem:uibarbuttonitem!     var refreshpagebutton:uibarbuttonitem!     var webview: wkwebview     var varintermediate = string()     let urlcontainer = streamplayer.sharedinstance.url  /**** javascript insertion *****/  required init?(coder adecoder: nscoder){     let config = wkwebviewconfiguration()     let scripturl = nsbundle.mainbundle().pathforresource("hidesectionsactu", oftype: "js")     let scriptcontent = try? string(contentsoffile:scripturl!, encoding:nsutf8stringencoding)     let script = wkuserscript(source: scriptcontent!, injectiontime: .atdocumentstart, formainframeonly: true)     config.usercontentcontroller.adduserscript(script)     self.webview = wkwebview(frame: cgrectzero, configuration: config)     super.init(coder: adecoder)     self.webview.navigationdelegate = self }    ////////////////////////////////////////////////    /**** view did load *****/  override func viewdidload() {     super.viewdidload()      self.backbuttonitem = uibarbuttonitem(title: "retour", style: uibarbuttonitemstyle.plain, target: self, action: "back:")     self.refreshpagebutton = uibarbuttonitem(barbuttonsystemitem: uibarbuttonsystemitem.refresh, target: self, action: "refresh:")      // webview creation//     webview.translatesautoresizingmaskintoconstraints = false     view.addsubview(webview)     webview.translatesautoresizingmaskintoconstraints = false     let height = nslayoutconstraint(item: webview, attribute: .height, relatedby: .equal, toitem: view, attribute: .height, multiplier: 1, constant: 0)     let width = nslayoutconstraint(item: webview, attribute: .width, relatedby: .equal, toitem: view, attribute: .width, multiplier: 1, constant: 0)     view.addconstraints([height, width])      webview.addobserver(self, forkeypath: "loading", options: .new, context: nil)      let url = nsurl(string: "myurl")     let request = nsurlrequest(url: url!)     webview.loadrequest(request)  } /////////////////////////////////////////// func webviewfunction(webview: wkwebview, didstartprovisionalnavigation navigation: wknavigation!) {  }  func webview(webview: wkwebview, didfinishnavigation navigation: wknavigation!) {      let javascriptstring : nsstring = "var el=document.getelementsbyclassname(\"home-link\")[0];el.removeattribute(\"href\");"      webview.evaluatejavascript(javascriptstring string, completionhandler: nil) } 

this code after "conversion" xcode 7

you should pay attention following 2 tips:

1.pay attention setting:

project/targets -> build settings -> build options -> embedded content contains swift code -> yes 

2.in plist file,you should add this:

<key>nsapptransportsecurity</key>     <dict>         <key>nsallowsarbitraryloads</key>         <true/>     </dict> 

for request non-https internet request if rebuild project xcode 7 or above.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -