Force App to stay in Landscape Mode
Good evening,
you helped me once and I hope you can help me again. I want my app to stay in landscape mode, even when the phone's turned again. I'm not sure if it's possible to start an app in landscape mode directly but as far as I've read through the Q&A, there's isn't a way to do that…
I have the following code:
var win = Titanium.UI.createWindow();
win.orientationModes = [ Titanium.UI.LANDSCAPE_LEFT ];
Then if I turn my phone to the left, the view is in the landscape mode, which is just fine, but then I want it to keep that mode but if I turn it again it switches to portrait mode. How can I prevent this?
I actually don't have a clue how to solve this problem. Sorry if it's an obviously stupid question but I hope you can help me out with this.
I'm running the script on an HTC Legend.
Thanks,
Michael
6 Answers
-
Try
// Set orientation Titanium.UI.orientation = Titanium.UI.LANDSCAPE_LEFT; //or _RIGHT
This should go on every window (or JS) you have.
Hope it helps. -
Thanks for your answer, but I couldn't solve the problem with that line of code. The app is still switching to portrait mode if I turn the phone. It starts in portrait mode too… Argh isn't there any way to solve this? This is really one thing that's blocking my whole app…
Thanks,
Michael
-
I have to agree, I have an App that needs to stay portait.
win2.orientationModes = [ Titanium.UI.PORTRAIT ];
That doesn't do anything, It's more than happy to rotate.
It doesn't make a difference if it's before or after the window.open, I'd try declaring it before the window, but that's just silly.Oh it's HTC Hero by the way, Running an official 2.1
-
does forcing Portrait in Android work yet? if so…how do we accomplish it?
-
a
-
https://developer.appcelerator.com/question/4981/how-to-set-landscape-mode has the answer.
For making the setting persist between program starts, use app properties http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.App.Properties