Search code examples
ioswebviewzoomingtitanium-sdk

Titanium SDK 8.2.0GA zoom in WebView not working


We are migrating existing Titanium classic apps to Titanium SDK 8.2.0GA and further on. We experience problems in activating the zoom / pinch-zoom functionality in iOS WebViews with loaded html pages. We assume the problem is due to the replacment of UiWebView with WKWebView but we can not see where we have to apply settings in order to re-enable zoom functionality. The html pages, including js and the rest of the apps work like a charm on 8.2.0GA...

Thank you for suggestions.

'Viewport setting works perfect in SDK 7.4.0 but does not zoom in SDK 8.2.0GA
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=10.0, user-scalable=yes"/>

'This is an example webview we use
var webView = Ti.UI.createWebView({
    left : gutter,
    top : gutter,
    right : gutter,
    bottom : gutter,
    // This allows the translucent view and the background to shine through. You could set this to a standard RGB color and change the opacity if desired.
    backgroundColor : translucentViewOn ? 'transparent' : backgroundColor,
    opacity : animationsOn ? 0 : 1,
    enableZoomControls : true, // Android only
    // Default assumes that all HTML is in the HTML folder and the first file is index.html, you can change the next line to suit your HTML.
    url : '/HTML/index.html'
});

Solution

  • In case, someone else needs zooming too. We found the correct settings:

    var webView = Ti.UI.createWebView({
    url: href,
    backgroundColor: "transparent", //not relevant for zooming
    borderWidth: 1,                 //not relevant for zooming
    scalesPageToFit: false,
    willHandleTouches: false,
    disableZoom: false
    });
    
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=10, user-scalable=yes"/>