uiwebview - how to give dynamic height to contentvie and webview in swift? -


 func webviewdidfinishload(webview: uiwebview) {     webview.stringbyevaluatingjavascriptfromstring("document.getelementsbytagname('body')[0].style.fontfamily =\"helveticaneue-light\"");     webview.stringbyevaluatingjavascriptfromstring("document.getelementsbytagname('body')[0].style.fontsize =\"20\"");      print(webview.request?.url)     self.bottomconstraint.constant = self.descriptionwebview.scrollview.contentsize.height     if (!observing) {         startobservingheight()     }      //self.bottomconstraint.constant = self.descriptionwebview.scrollview.contentsize.height  }   deinit {     stopobservingheight() }  func startobservingheight() {     let options = nskeyvalueobservingoptions([.new])     self.descriptionwebview.addobserver(self, forkeypath: "contentsize", options: options, context: &myobservationcontext)     observing = true; }  func stopobservingheight() {     self.descriptionwebview.removeobserver(self, forkeypath: "contentsize", context: &myobservationcontext)     observing = false }  override func observevalueforkeypath(keypath: string?, ofobject object: anyobject?, change: [string : anyobject]?, context: unsafemutablepointer<void>) {     guard let keypath = keypath else {         super.observevalueforkeypath(nil, ofobject: object, change: change, context: context)         return     }     switch (keypath, context) {     case("contentsize", &myobservationcontext):         self.bottomconstraint.constant = self.descriptionwebview.frame.size.height     default:         super.observevalueforkeypath(keypath, ofobject: object, change: change, context: context)     } } 

i have contentview has 1 label , webview, contentview height more webview im not able give dynamic height constraints in autolayouts in programatically have taken height constraint contentview , webview


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -