It seems like Ti can't lock orientation modes in specific windows when targeting the NavigationGroup root window.
Repro sequence set Root Window as LANDSCAPE, then when a child window is opened (in a navgroup) is not set whether PORTRAIT nor LANDSCAPE modes as specified.
var win = Ti.UI.createWindow({
backgroundColor:'gray'
});
var open = Ti.UI.createButton({
title:'Open nav group',
top:150,
width:200,
height:40
});
open.addEventListener('click', function() {
modal.open({modal:true});
});
win.add(open);
var modal = Ti.UI.createWindow({
//navBarHidden:true,
title:'ModalWin'
});
var modalWin = Ti.UI.createWindow({
backgroundColor:"red"
});
// initialize to LANDSCAPE MODE
modal.orientationModes = [
Titanium.UI.LANDSCAPE_LEFT,
Titanium.UI.LANDSCAPE_RIGHT,
];
var nav = Ti.UI.iPhone.createNavigationGroup({
window:modalWin
});
var table = Ti.UI.createTableView({
style:Ti.UI.iPhone.TableViewStyle.GROUPED,
data:[{title:"Well look at this"},{title:"TweetDeck is cool"}]
});
modalWin.add(table);
var done = Titanium.UI.createButton({
systemButton:Titanium.UI.iPhone.SystemButton.DONE
});
modalWin.setRightNavButton(done);
done.addEventListener('click',function()
{
modal.close();
});
table.addEventListener('click',function(e)
{
var b = Titanium.UI.createButton({
title:'Back (no anim)',
style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
b.addEventListener('click', function() {
nav.close(w,{animated:false});
});
var w = Ti.UI.createWindow({
title:e.rowData.title,
rightNavButton:b
});
// initialize to portrait modes
w.orientationModes = [
Titanium.UI.PORTRAIT,//Portrait mode is not set either
Titanium.UI.UPSIDE_PORTRAIT,//This window doesn't rotate
];
w.addEventListener('focus',function()
{
Ti.API.info("nav group window -- focus event");
});
w.addEventListener('blur',function()
{
Ti.API.info("nav group window -- blur event");
});
var b = Ti.UI.createButton({
title:"Close Nav",
width:120,
height:40
});
b.addEventListener('click',function()
{
modal.close();
});
w.add(b);
nav.open(w);
});
modal.add(nav);
modal.open();
This is because in our current implementation of navigationgroup, it is considered as view and not as view controller. SO it is not considered in the View hierarchy. We might want rethink the implementation of navigation group, for a proper fix to this problem, one that is in no way trivial.
The right fix to this problem, would require re-writing the entire navigationGroup for iOS to implement it properly. It can lead to a lot of regressions also. Considering the current time frame, going to move this ticket to be looked at after 3.0 release. While in the time being, one temporary solution that the user can have is changing the parent windows orientation when entering and exiting different views inside the navigation group. Modified code implementing this JS Fix :
Nowadays, using the
Ti.UI.iOS.NavigationWindow
, the orientation is managed by the containedTi.UI.Window
.Closing ticket as invalid with reference to the previous comments.