[TIMOB-4613] add Ti.UI.Window.orientation property
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2011-08-01T09:40:06.000+0000 |
| Affected Version/s | Release 1.7.1 |
| Fix Version/s | Sprint 2011-30, Release 1.8.0 |
| Components | TiAPI |
| Labels | qe-port |
| Reporter | Opie Cyrus |
| Assignee | Opie Cyrus |
| Created | 2011-07-07T08:09:51.000+0000 |
| Updated | 2012-08-17T03:04:18.000+0000 |
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()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