Forced Orientation (android) not working in 1.7.2

You must Login before you can answer or comment on any questions.

Hi, I have used the custom androidManifest xml approach to force portrait orientation. It was working fine in 1.7.1 but isn't working in 1.7.2 is this an issue or did something change?

— asked 2 years ago by Frank A
2 Comments
  • Hi, I have the same problem: Works in 1.7.1, does not work in 1.7.2...

    — commented 2 years ago by Tobias Jaecker

  • Have you entered a ticket?

    — commented 2 years ago by Frank A

3 Answers

Accepted Answer

Hi,

here is the solution (that worked for me):

You have to set the property "orientationModes" of your window object to [Ti.UI.PORTRAIT]...

AND... you have to do this outside of the createWindow Method. Only then the orientation is set. Here is my code:

var mainWindow = Ti.UI.createWindow({
            exitOnClose: true,
            name: 'mainWindow',
            windowSoftInputMode: Ti.UI.Android.SOFT_INPUT_ADJUST_PAN,
            navBarHidden: true,
            backgroundColor: 'white'
        });
 
mainWindow.orientationModes = [Ti.UI.PORTRAIT];

i don't know how you are structuring your apps, but i'm including a file on top of the code for every window used. inside this file that get's included everytime i put

// set portrait mode to all windows automatically
try {
 
    Ti.UI.orientation = Ti.UI.PORTRAIT;
 
} catch (e) {
 
 
}
to automatically set orientation to potrait mode, the try-catch comes to use, if included on top of the app.js

— answered 2 years ago by Christian Sigl
answer permalink
1 Comment
  • This work on Android? I thought for android you had to use the AndroidManifest.xml?

    — commented 2 years ago by Frank A

Unfortunately, this is still broken in 1.7.2. In fact, it's even more broken in 1.7.2 as the camera is now opposite to the orientation the app starts in.

Your Answer

Think you can help? Login to answer this question!