Webview autoheight to content is not working on iOS (Appcelerator Titanium) -


i want add webview height content. make running smoothly on android on ios longer text longer space below text is.

here code:

var window = ti.ui.createwindow();  var scrollview = ti.ui.createscrollview({     layout: 'vertical',     height: ti.ui.size });      var view1 = ti.ui.createview({         height: 200,         backgroundcolor: 'red'     });      var webview = ti.ui.createwebview({         height: ti.ui.size,              html: '<html><head><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><meta http-equiv="content-type" content="text/html; charset=iso-8859-2"></head><body style="margin:0; background-color: blue">some page text2</body></html>'     });      var view2 = ti.ui.createview({         height: 200,         backgroundcolor: 'green'     });      scrollview.add(view1);     scrollview.add(webview);     scrollview.add(view2);      window.add(scrollview);  window.open(); 

thanks in advance.

the webview doesn't know size of content. can ask webview how high content is.

for need use evaljs.

use js found on stackoverflow:

var body = document.body,     html = document.documentelement;  var height = math.max( body.scrollheight, body.offsetheight,                         html.clientheight, html.scrollheight, html.offsetheight ); 

and preferably put in function inside webview. lets above javascript in function getdocumentheight , function returns height property. now, height use eval this:

var height = webview.evaljs('getdocumentheight()'); webview.height = height; 

now, want execute every time content loaded, assuming content changes, in case can watch load event (doc here) , trigger evaljs above every time event fired.

it not pretty, webview not intended scale this, works.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -