Titanium JIRA Archive
Appcelerator Community (AC)

[AC-165] Unable to set layout for iPad in different Orientation for multiple window

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionCannot Reproduce
Resolution Date2015-11-14T01:59:13.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsios
Reportersuraj gupta
AssigneeShak Hossain
Created2015-06-15T12:14:55.000+0000
Updated2015-11-14T01:59:13.000+0000

Description

I have added eventListener for orientation change Ti.Gesture.addEventListener('orientationchange', function(e) { if (e.orientation === Titanium.UI.PORTRAIT || e.orientation === Titanium.UI.UPSIDE_PORTRAIT) { alert(e.orientation); } else if (e.orientation === Titanium.UI.LANDSCAPE_LEFT || e.orientation === Titanium.UI.LANDSCAPE_RIGHT) { alert(e.orientation); } }); And when I change the orientation it is fire but when I close the window and open it again then it does not fire. I also remove the listener on window close event Ti.Gesture.removeEventListener('orientationchange'); if orientation is applied to one window on orientationchange event then orientationchange event for other window does not fire

Comments

  1. Rakhi Mitro 2015-09-16

    Tested this issue using the sample code below. If you want to have some windows (or tabs) in one orientation and other windows in another orientation – enable each of the supported orientations in tiapp.xml, then specify each window's orientation using [win.orientationModes](http://docs.appcelerator.com/platform/latest/#!/guide/Orientation-section-29004932_Orientation Limitingorientationmodessupportedbyawindow) property. *Test Environments:* CLI Version :4.1.3 Titanium SDK Version:4.1.1.GA Device:iPad Appc Studio: Appcelerator Studio, build: 4.1.1.201507141126 Alloy: 1.7.6 Mac OS X,Version = 10.10.1. *Test Steps:* 1) Create classic project 2) Copy sample code to resource directory 3) Run project *Test code:* *app.js*
       
       // this sets the background color of the master UIView (when there are no windows/tab groups on it)
       Titanium.UI.setBackgroundColor('#000');
       
       // create tab group
       var tabGroup = Titanium.UI.createTabGroup();
       
       
       //
       // create base UI tab and root window
       //
       var win1 = Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'#fff'
       });
       win1.orientationModes = [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT,Titanium.UI.LANDSCAPE_LEFT,Titanium.UI.LANDSCAPE_RIGHT];
       
       var tab1 = Titanium.UI.createTab({  
           icon:'KS_nav_views.png',
           title:'Tab 1',
           window:win1
       });
       
       var label1 = Titanium.UI.createLabel({
       color:'#999',
       text:'I am Window 1',
       font:{fontSize:20,fontFamily:'Helvetica Neue'},
       textAlign:'center',
       width:'auto'
       });
       
       win1.add(label1);
       
       //
       // create controls tab and root window
       //
       var win2 = Titanium.UI.createWindow({  
           title:'Tab 2',
           backgroundColor:'#fff'
       });
       win2.orientationModes = [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT,Titanium.UI.LANDSCAPE_LEFT,Titanium.UI.LANDSCAPE_RIGHT];
       var tab2 = Titanium.UI.createTab({  
           icon:'KS_nav_ui.png',
           title:'Tab 2',
           window:win2
       });
       
       var label2 = Titanium.UI.createLabel({
       color:'#999',
       text:'I am Window 2',
       font:{fontSize:20,fontFamily:'Helvetica Neue'},
       textAlign:'center',
       width:'auto'
       });
       
       win2.add(label2);
       
       
       
       Ti.Gesture.addEventListener('orientationchange', function(e) {
       if (e.orientation === Titanium.UI.PORTRAIT || e.orientation === Titanium.UI.UPSIDE_PORTRAIT)
       { 
       alert(e.orientation);
       Ti.API.info("orentation is"+e.orientation);
       }
       else if (e.orientation === Titanium.UI.LANDSCAPE_LEFT || e.orientation === Titanium.UI.LANDSCAPE_RIGHT)
       { 
       alert(e.orientation); 
       Ti.API.info("orentation is"+e.orientation);
       }
       });
       //
       //  add tabs
       //
       tabGroup.addTab(tab1);  
       tabGroup.addTab(tab2);  
       
       
       // open tab group
       tabGroup.open();
       
       
         
    **Test Result*:* Different Orientation for multiple windows in iPad is working as expected.Check [it](http://i57.tinypic.com/25pkdxt.png) for window one and [this](http://i57.tinypic.com/1038ia0.png) for window two using tab group. If you observe different results, please post runnable sample code.

JSON Source