ios - Swift UIWebView initial zoom scale -


hey asked similar question days ago no on me , no i'm think im closer problem. have webview on rootviewcontroller , saved values zoom scale , position of local pdf, want set webview values when appears tried following.

   override func viewdidappear(animated: bool) {      dolayoutthings()   }     func dolayoutthings(){      if(defaults.objectforkey("positiony") != nil){           webview.scrollview.setzoomscale(defaults.objectforkey("zoomlevel") as! cgfloat, animated: false)         let offest = cgpoint(x: defaults.objectforkey("positionx") as! cgfloat, y: defaults.objectforkey("positiony") as! cgfloat)         webview.scrollview.setcontentoffset(offest, animated:false)         println(defaults.objectforkey("zoomlevel") as! cgfloat)         } 

i know there correct values saved userdefaults webview looks if didn't make scrolling or zooming. i'm happy solution ideas.

setting zoom scale in viewdidappear fine cannot set contentoffset before web view has loaded content. have set delegate on uiwebview , set contentoffset in delegate method:

override func viewdidload() {    webview.delegate = self }  func webviewdidfinishload(webview: uiwebview) {     let offset = cgpoint(x: defaults.objectforkey("positionx") as! cgfloat, y: defaults.objectforkey("positiony") as! cgfloat)     webview.scrollview.setcontentoffset(offset, animated: false) } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -