i'm developing ios app have display html code downloaded server.
my view composed of grouped tableview, 1 cell per section , cell composed uiwebview has display html code.
i don't want uiwebview scrollable up/down, want allow right/left scrolling, want set height of content.
i read lot of topics problem solution functional me.
what strange according me cells right height , it's correctly set not every cells ...
this code tried (with several tests still written) :
func webviewdidfinishload(webview: uiwebview) { webview.scrollview.scrollenabled = false let size = self.sizethatfits(cgsizemake(self.frame.width, cgfloat(flt_max))) self.frame = cgrectmake(0, 0, self.frame.width, size.height); let test1 = webview.stringbyevaluatingjavascriptfromstring("document.body.offsetheight;") let test2 = webview.stringbyevaluatingjavascriptfromstring("document.body.scrollheight;") let test3 = webview.stringbyevaluatingjavascriptfromstring("document.documentelement.scrollheight;") let height = cgfloat(double(test2!)!) if(self.containingvc infodrugviewcontroller){ let vc = self.containingvc as! infodrugviewcontroller vc.heightready(height, index: self.index.section) }else{ if (self.containingvc infoprotocolviewcontroller){ let vc = self.containingvc as! infoprotocolviewcontroller vc.heightready(height, index: self.index.section) } } }
if knows how managed right height, it'll perfect !
(note html code downloaded server , generated wysiwyg (ckeditor) textfield website.)
it find working solution, maybe it's no cleanest one, @ least works :
func webviewdidfinishload(webview: uiwebview) { webview.scrollview.scrollenabled = false var frame = self.frame frame.size.width = self.containingvc.view.frame.size.width frame.size.height = 1 self.frame = frame frame.size.height = self.scrollview.contentsize.height self.frame = frame let test0 = self.scrollview.contentsize.height let size = self.sizethatfits(cgsizemake(self.frame.width, cgfloat(flt_max))) self.frame = cgrectmake(0, 0, self.frame.width, size.height); let test1 = cgfloat(double(webview.stringbyevaluatingjavascriptfromstring("document.body.offsetheight;")!)!) let test2 = cgfloat(double(webview.stringbyevaluatingjavascriptfromstring("document.body.scrollheight;")!)!) let test3 = cgfloat(double(webview.stringbyevaluatingjavascriptfromstring("document.body.clientheight")!)!) let test4 = cgfloat(double(webview.stringbyevaluatingjavascriptfromstring("document.documentelement.scrollheight;")!)!) let test5 = cgfloat(double(webview.stringbyevaluatingjavascriptfromstring("document.documentelement.clientheight")!)!) let test6 = cgfloat(double(webview.stringbyevaluatingjavascriptfromstring("document.documentelement.offsetheight")!)!) print("0: \(test0) | 1: \(test1) | 2: \(test2) | 3: \(test3) | 4: \(test4) | 5: \(test5) | 6: \(test6)") let height = max(test0, test1, test2, test3, test4, test5, test6) if(self.containingvc infodrugviewcontroller){ let vc = self.containingvc as! infodrugviewcontroller vc.heightready(height, index: self.index.section) }else{ if (self.containingvc infoprotocolviewcontroller){ let vc = self.containingvc as! infoprotocolviewcontroller vc.heightready(height, index: self.index.section) } } self.scrollview.scrollenabled = true }
Comments
Post a Comment