Device Rotation

Okay guys this one seems pretty simple, but I’m not finding anything really talking about what’s going on. At work I use Telerik AppBuilder to compile and deploy the app I’m creating at work. So far I’ve enjoyed what I’m doing at work so much I wanted to work on personal apps at home (yay for good career choice). I didn’t want to pay for a build service, and happen to have a mac to develop on at home.

I’ve got all the prerequisites lined up, node, npm, git, ionic, cordova, xcode, whole 9 yards. After opening my project in xcode to get the proper code signing done so I can deploy to device I close xcode hoping to never look back. Deploys just fine using ionic run ios --device.

My app does NOT respond to device rotation on iphone or ipad. I’ve tried adding the Orientation preference to config.xml, I’ve tried checking the rotation settings in xcode. All to no avail! I went back to square one to see if it was me, but just deploying the ionic sidemenu template to device does NOT rotate.

This has caught me off guard since at work, (even though it’s a different environment using AppBuilder), the app responded to device rotation out of the box. Please help me figure this one out.

For anyone interested I found the solution for myself. I am using the most current version of cordova (5.4.0), and the documentation for that version suggests this setting in config.xml to support rotation:

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

I found that following the documentation for cordova (5.0.0) contained the config.xml settings that ended up working for me:

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

in addition to this global function being present:

`/**

  • @param {Number} degree - UIInterfaceOrientationPortrait: 0, UIInterfaceOrientationLandscapeRight: 90, UIInterfaceOrientationLandscapeLeft: -90, UIInterfaceOrientationPortraitUpsideDown: 180
  • @returns {Boolean} Indicating if rotation should be allowed.
    */
    function shouldRotateToOrientation(degrees) {
    return true;
    }`

Just absolutely silly if you ask me, I would prefer the solution suggested in the cordova 5.4.0 documentation compared to this. But I guess whatever works!