Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25961] iOS: e.orientation always returns 5 for landscape to FACE_UP and portrait to FACE_UP.

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionInvalid
Resolution Date2018-04-13T14:20:31.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsescalation
ReporterMotiur Rahman
AssigneeRene Pot
Created2018-04-13T03:10:50.000+0000
Updated2018-08-06T17:37:06.000+0000

Description

Basically, need to maintain the onset of UI when we in portrait and move up & down. Also another set of UI when are in landscape and move up&down. Eg: if( e.orientation === Ti.UI.PORTRAIT && e.orientation === Titanium.UI.FACE_UP){ updateUI(); } Also, if( (e.orientation === Ti.UI.LANDSCAPE_LEFT || e.orientation === Ti.UI.LANDSCAPE_RIGHT) && e.orientation === Titanium.UI.FACE_UP){ updateUI() } But it does not work. *Test Code:*
Ti.Gesture.addEventListener('orientationchange', function(e) {

	if (e.orientation == Titanium.UI.FACE_DOWN) {

		Ti.API.info("ORientation_FACE_DOWN:" + e.orientation);

	} else if (e.orientation == Titanium.UI.FACE_UP) {

		Ti.API.info("ORientation_FACE_UP:" + e.orientation);

	} else if (e.orientation == Titanium.UI.PORTRAIT) {
		Ti.API.info("ORientation_PORTRAIT:" + e.orientation);

	} else if (e.orientation == Titanium.UI.UPSIDE_PORTRAIT) {
		Ti.API.info("ORientation_UPSIDE_PORTRAIT:" + e.orientation);

	} else if (e.orientation == Titanium.UI.LANDSCAPE_LEFT) {
		Ti.API.info("ORientation_LANDSCAPE_LEFT:" + e.orientation);

	} else if (e.orientation == Titanium.UI.LANDSCAPE_RIGHT) {
		Ti.API.info("ORientation_LANDSCAPE_RIGHT:" + e.orientation);

	} else {
		Ti.API.info("ORientation_UNKNOWN:" + e.orientation);

	}

	if (e.orientation == Titanium.UI.PORTRAIT && e.orientation == Titanium.UI.FACE_UP) {

	//issue is here: cannot detect this position
       Ti.API.info("ORientation_PORTRAIT_FACE_UP:" + e.orientation);
	}

	if ((e.orientation == Ti.UI.LANDSCAPE_LEFT || e.orientation == Ti.UI.LANDSCAPE_RIGHT) && e.orientation == Titanium.UI.FACE_UP) {
         //issue is here: cannot detect this position
		Ti.API.info("ORientation_LANDSCAPE_:FACE_UP" + e.orientation);
	}

	
});
Thanks.

Comments

  1. Rene Pot 2018-04-13

    Orientation cannot have 2 states, it is either face up or landscape. Cannot be both at the same time. If you want to render differently if it was landscape or portrait before moving down, you'll need to store the value in a variable that you will not override when FACE_UP and FACE_DOWN statuses are triggered.
  2. Hans Knöchel 2018-04-13

    Rene is correct. In addition, you have to distinguish between device- and screen orientation. Here is an example:
       Ti.Gesture.addEventListener('orientationchange', function(e) {
           if (e.orientation == Titanium.UI.FACE_DOWN && Ti.Gesture.landscape) {
               // Face down and landscape (left or right)
           } else if (e.orientation == Titanium.UI.FACE_DOWN && Ti.Gesture.portrait) {
               // Face down and portrait
           }
       });
       
  3. Rene Pot 2018-04-13

    As this is not a bug I'm resolving it as "invalid"
  4. Eric Merriman 2018-08-06

    Closing as invalid. If incorrect, please reopen.

JSON Source