Ionic app will not switch orientation when iPad is rotated

I’m building an iPad/iPhone app, and I started with the “sidemenu” starter app.

When I run the app in both the simulator and device and rotate the orientation between portrait and landscape, the app does nothing - it is stuck in portrait view. I know that the device itself does not have any orientation locks on because the home screen and other apps will respond to the orientation change without issue.

I’ve tried messing with the config.xml options (adding <preference name="orientation" value="landscape"/>), but all that does is lock the app in landscape view rather than allowing it to switch between portrait and landscape. Is there some setting that I’m missing that can enable dynamically switching between orientations?

2 Likes

The only setting I know is changing the value to default.

<preference name="orientation" value="default" />

give it a shot.

2 Likes

Thanks for the suggestion. I changed the value to what you recommended and that didn’t seem to have any effect.

I tried a completely vanilla version of the sidemenu and tabs starters - I didn’t make any changes at all and immediately ran them in an iPad simulator and the orientation won’t change. Is there something I need to do in my JavaScript to detect that the orientation changed and instruct the app to redraw itself? I didn’t find any documentation about that anywhere.

Not sure it this applies: Ionic app does not auto-rotate on mobile but does on Tablet

I wanted to provide an UPDATE. I looked through the Cordova (not Ionic) documentation and discovered that the proper tag to add in the config.xml file is the following:

<platform name="ios">
    <preference name="Orientation" value="all" />
</platform>

The full documentation for this is found here: https://cordova.apache.org/docs/en/5.1.1/config_ref_index.md.html#The%20config.xml%20File

16 Likes

OMG it worked. I just spent 12 hours trying solve it. Adding to the config file solved it!