Search code examples
webviewtitaniumappceleratortitanium-mobileappcelerator-mobile

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


I want to add webview which height would be as it content. I make it running smoothly on Android but on iOS the longer the text is the longer space below text is.

Here is my 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 some 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.


Solution

  • It seems it's a bug / discouraged method for iOS. No direct workaround. Can be checked here: Jira Ticket about problem with iOS 9, Jira Ticket about problem with webView + ScrollView