Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova: How to lock app orientation at boot to landscape and not landscape-reverse?

I'm building a tilt-based game and want to lock the orientation to 1 particular landscape orientation (UIInterfaceOrientationLandscapeRight on iOS). However, if you set the cordova Orientation preference to landscape, it can still rotate 180 degrees to either landscape mode, which isn't acceptable for me. Is this a shortcoming of cordova? I need this, and it's trivial to do natively, so seems like there ought be an easy way to do it.

I'm aware of cordova-plugin-screen-orientation, but it only does stuff once your javascript has started running, which is too late for your splash screen.

like image 893
frodo2975 Avatar asked Oct 19 '25 22:10

frodo2975


1 Answers

Currently I am finding the answer for Android and the accepted answer cannot be used now. In Cordova root folder config.xml add:

<platform name="android">
        <preference name="orientation" value="landscape" />
</platform>

Then the app will be landscaped.

like image 83
Mingze Li Avatar answered Oct 22 '25 11:10

Mingze Li



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!