[TIMOB-25961] iOS: e.orientation always returns 5 for landscape to FACE_UP and portrait to FACE_UP.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2018-04-13T14:20:31.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | escalation |
Reporter | Motiur Rahman |
Assignee | Rene Pot |
Created | 2018-04-13T03:10:50.000+0000 |
Updated | 2018-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.
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.
Rene is correct. In addition, you have to distinguish between device- and screen orientation. Here is an example:
As this is not a bug I'm resolving it as "invalid"
Closing as invalid. If incorrect, please reopen.