Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18789] iOS: Can not Get Correct Orientation Information when orientation is not portrait

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2015-04-29T16:20:33.000+0000
Affected Version/sRelease 3.5.1
Fix Version/sn/a
ComponentsiOS
Labelsorientation, orientationChange
ReporterShuo Liang
AssigneeIngo Muschenetz
Created2015-04-08T10:33:44.000+0000
Updated2017-03-22T20:56:37.000+0000

Description

Description:

Using window.getOrientation() can't get correct info if orientationModes is not portrait.

Reproduce Step:

Simply run the test case in classic project. (force Orientation to Landscape_Right)
var self = Ti.UI.createWindow({ 
backgroundColor:'#ffffff', 
orientationModes : [Ti.UI.LANDSCAPE_RIGHT]	
}); 
Ti.API.debug('Reference'); 
Ti.API.debug('Ti.UI.LANDSCAPE_RIGHT:' + Ti.UI.LANDSCAPE_RIGHT); 
Ti.API.debug('Ti.UI.LANDSCAPE_LEFT:' + Ti.UI.LANDSCAPE_LEFT); 
Ti.API.debug('Ti.UI.PORTRAIT:' + Ti.UI.PORTRAIT); 
Ti.API.debug('Ti.UI.UPSIDE_PORTRAIT:' + Ti.UI.UPSIDE_PORTRAIT); 

var label = Ti.UI.createLabel({
	text: "Test Window for Orientation!",
	Top: '30%',
});
self.add(label);

//construct UI 
self.addEventListener('open', function(e) { 
Ti.API.debug('When Opened, Window Orientation:' + self.getOrientation() + ", Gesture Orientaiton:" + Ti.Gesture.getOrientation()); 
}); 
self.addEventListener('focus', function(e) { 
Ti.API.debug('When Focussed, Window Orientation:' + self.getOrientation() + ", Gesture Orientaiton:" + Ti.Gesture.getOrientation()); 
}); 
Ti.Gesture.addEventListener('orientationchange', function(e) { 
Ti.API.debug('Window Orientation:' + self.getOrientation() + ", Gesture Orientaiton:" + Ti.Gesture.getOrientation()); 
}); 
self.open();

Expect Result:

Should get the correct information about orientation.

Actual Result:

Window opens in landscape mode as expected, but none of the event listeners configured as in the above code log the correct orientation
[DEBUG] : Reference 
[DEBUG] : Ti.UI.LANDSCAPE_RIGHT:3 
[DEBUG] : Ti.UI.LANDSCAPE_LEFT:4 
[DEBUG] : Ti.UI.PORTRAIT:1 
[DEBUG] : Ti.UI.UPSIDE_PORTRAIT:2 
[DEBUG] : Loading: /Users/achyutjoshi/Library/Developer/CoreSimulator/Devices/DEE57654-B959-4BB6-942A-370CD35E6CDC/data/Containers/Bundle/Application/EEFFC1D4-C8D4-48F0-9783-C26BAC2992EE/orientation.app/_app_props_.json, Resource: _app_props__json 
[DEBUG] : Forcing rotation to 3. Current Orientation 1. This is not good UI design. Please reconsider. 
[DEBUG] : Application booted in 130.232036 ms 
[DEBUG] : When Opened, Window Orientation:1, Gesture Orientaiton:1 
[DEBUG] : When Focussed, Window Orientation:1, Gesture Orientaiton:1 

Note:

If run the test code on Android device, the result will show the orientation change. like this:
[DEBUG] : Reference 
[DEBUG] : Ti.UI.LANDSCAPE_RIGHT:4 
[DEBUG] : Ti.UI.LANDSCAPE_LEFT:2 
[DEBUG] : Ti.UI.PORTRAIT:1 
[DEBUG] : Ti.UI.UPSIDE_PORTRAIT:3 
[INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.orientation.OrientationActivity@421c5c30 
[INFO] : I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018_msm8226_LNX.LA.3.5.1_RB1__release_AU () 
[INFO] : I/Adreno-EGL: OpenGL ES Shader Compiler Version: E031.24.00.08 
[INFO] : I/Adreno-EGL: Build Date: 03/07/14 Fri 
[INFO] : I/Adreno-EGL: Local Branch: 
[INFO] : I/Adreno-EGL: Remote Branch: quic/LNX.LA.3.5.1_RB1.1 
[INFO] : I/Adreno-EGL: Local Patches: NONE 
[INFO] : I/Adreno-EGL: Reconstruct Branch: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018 + f2fd134 + NOTHING 
[DEBUG] : OpenGLRenderer: Enabling debug mode 0 
[DEBUG] : Window: Checkpoint: postWindowCreated() 
[DEBUG] : When Opened, Window Orientation:1, Gesture Orientaiton:1 
[DEBUG] : When Focussed, Window Orientation:1, Gesture Orientaiton:1 
[DEBUG] : Window Orientation:2, Gesture Orientaiton:2 

Comments

  1. Vishal Duggal 2015-04-29

    Using the orientationModes property to force the orientation of non-modal windows is considered a bad practice and will not be supported. See http://docs.appcelerator.com/titanium/release-notes/?version=3.4.0.GA#changes Two options: 1. Make the window modal so it can have orientations outside those specified by tiapp.xml 2. Ensure that the supported orientation in tiapp.xml for iPhone idiom is set to LANDSCAPE_RIGHT
  2. Lee Morris 2017-03-22

    Closing ticket as invalid with reference to the above comments.

JSON Source