Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5086] iOS: OrientationModes in NavigationGroup windows can't be locked

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2016-10-18T12:37:29.000+0000
Affected Version/sRelease 1.7.1, Release 2.1.1, Release 3.0.2
Fix Version/sn/a
ComponentsiOS
LabelsSupportTeam, dev-invalidate, ios, navgroup, orientation
ReporterEduardo Gomez
AssigneeEric Merriman
Created2011-08-23T11:49:15.000+0000
Updated2017-03-23T21:32:57.000+0000

Description

Problem

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.

Tested on

Simulator iOS 4.3 & iPod device

Repro sequence

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();

Associated HD ticket

#APP-293437

Comments

  1. Sabil Rahim 2012-09-10

    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.
  2. Sabil Rahim 2012-09-11

    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 :
       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
           });
       // This will not work.       
       //     // 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");
       		modal.orientationModes = [
       	    Titanium.UI.PORTRAIT,//Portrait mode is not set either
       	    Titanium.UI.UPSIDE_PORTRAIT,//This window doesn't rotate
       		]; 
           });
           w.addEventListener('blur',function()
           {
               Ti.API.info("nav group window -- blur event");
       		modal.orientationModes = [
       		    Titanium.UI.LANDSCAPE_LEFT,
       		    Titanium.UI.LANDSCAPE_RIGHT,
       		];
           });
           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();
       
  3. Hans Knöchel 2016-10-18

    Nowadays, using the Ti.UI.iOS.NavigationWindow, the orientation is managed by the contained Ti.UI.Window.
  4. Lee Morris 2017-03-23

    Closing ticket as invalid with reference to the previous comments.

JSON Source