titaniumtitanium-alloy

How to reset the orientation of main window in Titanium using Alloy?


My main window(index.xml) has its orientation properties set like this:

orientationModes: [
        Ti.UI.PORTRAIT,
        Ti.UI.UPSIDE_PORTRAIT
    ],

Now i have a button in main window,which opens another window(say Gallery.xml) after clicking on it.

Orientation modes for Gallery.xml is :

orientationModes: [
    Ti.UI.LANDSCAPE_RIGHT,
    Ti.UI.LANDSCAPE_LEFT
]

Whenever i tap on this button, Gallery.xml opens up in landscape mode & after closing the Gallery.xml window, main window again turns into portrait mode.

But this series of orientation works only for two or three times,after that main window sets out to only landscape mode & then never gets changed.

It would be very helpful if someone could tell me that how should i handle this functionality,to keep main window in portrait mode & gallery window in landscape mode only ?


Solution

  • to keep main window in portrait mode & gallery window in landscape mode only ?

    You can use orientation property of the window.

    So in your main.xml or main.tss add this orientation property in the root window. Example:

    <Window id="main" orientation=Titanium.UI.PORTRAIT >
        <Button>Test</Button>
    </Window>
    

    Similarly in Gallery.xml or Gallery.tss add orientation property in window to restrict in landscape mode. Example:

    <Window id="gallery" orientation=Titanium.UI.LANDSCAPE_LEFT >
        <Button>Test</Button>
    </Window>