Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Webview fails in orientationchange event

I have a view that will show different content at the PORTRAIT view and at the LANDSCAPE's views. The PORTRAIT view is all titanium controls and the LANDSCAPE view is a webview. I am working with IPhone, titanium sdk 1.4.1.1 and MacOSX 10.6.4.

First I asign the portrait orientation mode to the actual view:


var thisWin = Titanium.UI.currentWindow;
thisWin.orientationModes = [
Titanium.UI.PORTRAIT
];

At the end of the script I create a new window for the LANDSCAPE view, create the webview and add it to the window:


winChart = Titanium.UI.createWindow({
    title:'',
    orientationModes:[Titanium.UI.LANDSCAPE_LEFT,Titanium.UI.LANDSCAPE_RIGHT]
});

webview = Titanium.UI.createWebView({
   url:'http://www.internet.ingdirect.dev.is-teledata.com/www/horizontal_graph.html?ID_NOTATION='+Ti.UI.currentWindow.id_notation ,
    top:0
 });

  winChart.add(webview);

Finally I add the orientationchange listener to open and close both windows:


Ti.Gesture.addEventListener('orientationchange', function(e){


    switch (e.orientation) {
        case 1:
            winChart.close({transition:Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT});
            Titanium.UI.iPhone.showStatusBar();
            break;
        case 3:
            Titanium.UI.iPhone.hideStatusBar();
            Ti.UI.orientation = Titanium.UI.LANDSCAPE_RIGHT;

            winChart.open({transition:Ti.UI.iPhone.AnimationStyle.FLIP_FROM_RIGHT});
            break;
        case 4:
            Titanium.UI.iPhone.hideStatusBar();
            Ti.UI.orientation = Titanium.UI.LANDSCAPE_LEFT;

            winChart.open({transition:Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT});
            break;
        }
});

The result is that the first time I change orientation from PORTRAIT to LANDSCAPE_LEFT the windows close and open correctly, but when I change orientation the second time from PORTRAIT to LANDSCAPE_LEFT it doesn't open the new window.

I tried this code with elements other than webviews and it works fine but it is when it cames to a webview then it doesn't show it.

I know this appears to be a bug but any tip would be appreciated!!

Thanks
Pablo

— asked November 4th 2010 by pablo espinosa
  • orientation
  • webview
0 Comments

1 Answer

  • i think this ticket is related to your issue

    https://appcelerator.lighthouseapp.com/projects/32238/tickets/1145-android-orientation-issues

    — answered November 5th 2010 by Aaron Saunders
    permalink
    1 Comment
    • Thank you very much Aaron. I am working with Iphone and that ticket is related to android, I think. Anyway, if it was related to my issue, is it already fixed or not?

      — commented November 5th 2010 by pablo espinosa
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.