I did not have any luck with changing a windows orientationModes on runtime too. The docs say that the window property orientationModes
as well as its method setOrientationModes
have to be set before opening the window.
So switching from views to windows is not an option?
If you want a window to allow orientations different from those defined in tiapp.xml, you have to set orientationModes on every window individually:
// This window allows orientations defined in tiapp.xml
var appWin = Ti.UI.createWindow({
backgroundColor = '#FFF'
});
appWin.open();
// This window is portrait only
var win = Ti.UI.createWindow({
backgroundColor: '#FFF',
orientationModes: [Ti.UI.PORTRAIT]
});
win.open();
// If this window is opened it allows multiple orientations
var newWindow = Ti.UI.createWindow({
backgroundColor: '#FFF',
orientationModes: [Ti.UI.PORTRAIT, Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT]
});
newWindow.open()
This is tested with SDK 3.1.3.
Edit
To make this work on Android, you have to force a heavyweight window by either setting fullscreen: true
or navBarHidden: true