Search code examples
titaniumappcelerator

Titanium - Reset zoom scale in webview


Is it possible to programmatically reset the zoom/scale that the user has done in a webview? My issue is when the webview is pinch zoomed in landscape and you rotate the phone, the webview is still zoomed in and in my case, portrait mode is now extremely zoomed in.

I've tried webview.repaint() but that seems to do absolutely nothing. I know I can call webiew.reload() but that just uses more bandwidth for my server as well as the users data plan so I want to avoid that.

I'm using Titanium Studio, build: 3.1.3.xxx, 3.1.3 GA Ti SDK and compiling for iOS 7 SDK.


Solution

  • Based on this thread and the fact that there was no way to easily achieve this, I have created a module. It extends the Ti.UI.WebView with two methods, setZoomLevel() and scrollToTop(). It is very basic at the moment, but I'm planning on extending its functionality gradually.

    https://github.com/mwfire/titanium-module-extended-webview

    Have a look, it's an alternative to modifying the core code.