Device Orientation Not Working?

8 posts, 0 answers
  1. Brad
    Brad avatar
    30 posts
    Member since:
    Sep 2010

    Posted 25 Dec 2012 Link to this post

    I'm having a bit of trouble with screen orientation.  In the project properties, Portrait and Landscape are both marked as supported.  Also, if I use the emulator, screen rotation works.  However, when testing on an actual device, (iPad 3) the only rotated portion of the program is the splash screen.  The rest is always constrained in Portrait.

    Any suggestions?

    Thanks
  2. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 27 Dec 2012 Link to this post

    Hello Brad,

     Are you using Icenium Ion to test your app on your iPad? If not, could you please tell me what Cordova version you're building your project against?

    Greetings,
    Yavor Georgiev
    the Telerik team

    Share feedback and vote for features on our Feedback Portal.
    Want some Kendo UI online training - head over to Pluralsight.
  3. Brad
    Brad avatar
    30 posts
    Member since:
    Sep 2010

    Posted 28 Dec 2012 Link to this post

    I didn't realize Cordova was what handled the orientation.  I'll go back and check my initialization first to ensure I haven't messed something up before wasting your time.  I know you guys are busy.

    Thanks.
  4. Brad
    Brad avatar
    30 posts
    Member since:
    Sep 2010

    Posted 03 Jan 2013 Link to this post

    Properties > General

    Changed Cordova version from 2.0.0 to 2.2.0

    It now works.

    Thanks
  5. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 05 Sep 2013 Link to this post

    Sorry for reviving an old thread, but I am experiencing exactly the same problem as topic starter describes in his first post.

    Using:
    - latest Kendo UI
    - SQLite plugin
    - Cordova 2.7.0

    Is this a known issue with this version of Cordova?
  6. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 06 Sep 2013 Link to this post

    I have this in my deviceReady function:
    window.onorientationchange = function () {
        //Need at least 800 milliseconds
        setTimeout(changeOrientation, 1000);
    }

    and this is the changeOrientation function:
    function changeOrientation() {
        alert('Begin: changeOrientation');
        switch (window.orientation) {
            case 0:
                // portrait, home bottom
                alert('portrait, home bottom (0 degrees)');
            case 180:
                // portrait, home top
                alert("portrait (180 degrees) H: " + $(window).height() + " W: " + $(window).width());
                break;
            case -90:
                // landscape, home left
                alert('landscape, home left (-90 degrees)');
            case 90:
                // landscape, home right
                alert("landscape (90 degrees) H: " + $(window).height() + " W: " + $(window).width());
                break;
        }
        alert('End: changeOrientation');
    }


  7. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 09 Sep 2013 Link to this post

    Hello JD,

    There is no reason to write javascript for controlling the orientation manually, Cordova already does that for you automatically by setting "Supported Interface Orientation" (set by default btw) and having the viewport meta to your html file:

    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, target-densitydpi=device-dpi" />

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  8. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 09 Sep 2013 Link to this post

    Thank you Steve, but I am aware of that possibility.

    However, I want to have control over when the app can allow orientation change and when not.
Back to Top