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.
Found a solution: cordova allows you to edit native attributes through your config.xml file. I feel this ought to be supported natively by cordova itself, but this will work:
<platform name="android">
<edit-config
file="AndroidManifest.xml"
target="/manifest/application/activity[@android:name='MainActivity']"
mode="merge"
xmlns:android="http://schemas.android.com/apk/res/android">
<activity android:screenOrientation="landscape"></activity>
</edit-config>
</platform>