Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4613] add Ti.UI.Window.orientation property

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2011-08-01T09:40:06.000+0000
Affected Version/sRelease 1.7.1
Fix Version/sSprint 2011-30, Release 1.8.0
ComponentsTiAPI
Labelsqe-port
ReporterOpie Cyrus
AssigneeOpie Cyrus
Created2011-07-07T08:09:51.000+0000
Updated2012-08-17T03:04:18.000+0000

Description

Comments

  1. Opie Cyrus 2011-07-27

    Fix can be verified with the following test code:
       Titanium.UI.setBackgroundColor('#000');
       var win = Titanium.UI.createWindow({  
           title:'Test',
           backgroundColor:'#000',
       	exitOnClose: true
       });
       
       // initialize to all modes
       win.orientationModes = [
       	Titanium.UI.PORTRAIT,
       	Titanium.UI.UPSIDE_PORTRAIT,
       	Titanium.UI.LANDSCAPE_LEFT,
       	Titanium.UI.LANDSCAPE_RIGHT,
       	Titanium.UI.FACE_UP,
       	Titanium.UI.FACE_DOWN
       ]; 
       
       
       //
       // helper function
       //
       function getOrientation(o)
       {
       	switch (o)
       	{
       		case Titanium.UI.PORTRAIT:
       			return 'portrait';
       		case Titanium.UI.LANDSCAPE_LEFT:
       			return 'landscape';
       		case Titanium.UI.UNKNOWN:
       			return 'unknown';
       	}
       }
       
       //
       // get current orientation
       //
       var l = Titanium.UI.createLabel({
       	color:'#999',
       	text:'Current Orientation: ' + getOrientation(Titanium.Gesture.orientation),
       	top:10,
       	width:300,
       	height:'auto',
       	textAlign:'center'
       });
       win.add(l);
       
       //
       // orientation change listener
       //
       Ti.Gesture.addEventListener('orientationchange',function(e)
       {
       	// device orientation
       	l.text = 'Current Window Orientation: ' + getOrientation(win.orientation);
       	
       	// get orienation from event object
       	var orientation = getOrientation(e.orientation);
       	
       	Titanium.API.info("orientation changed = "+orientation+", is portrait?"+e.source.isPortrait()+", window orientation = "+ win.orientation + "is landscape?"+e.source.isLandscape());
       });
       
       win.open()
       
  2. Shyam Bhadauria 2012-08-17

    Environment used for verification - Tested with Titanium SDK: 2.2.0.v20120816212512 Tested with Titanium  Studio: 2.1.1.201207271312 Device - Samsung GALAXY Note Android 2.3.6 Machine OS - MAC 10.8

JSON Source