This is a migrated thread and some comments may be shown as answers.

Device Orientation Not Working?

7 Answers 195 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brad
Top achievements
Rank 1
Brad asked on 25 Dec 2012, 01:16 PM
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

7 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 27 Dec 2012, 06:56 PM
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.
0
Brad
Top achievements
Rank 1
answered on 28 Dec 2012, 01:28 PM
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.
0
Brad
Top achievements
Rank 1
answered on 03 Jan 2013, 09:59 PM
Properties > General

Changed Cordova version from 2.0.0 to 2.2.0

It now works.

Thanks
0
Jan-Dirk
Top achievements
Rank 1
answered on 05 Sep 2013, 03:36 PM
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?
0
Jan-Dirk
Top achievements
Rank 1
answered on 06 Sep 2013, 08:38 AM
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');
}


0
Steve
Telerik team
answered on 09 Sep 2013, 03:44 PM
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.
0
Jan-Dirk
Top achievements
Rank 1
answered on 09 Sep 2013, 06:16 PM
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.
Tags
General Discussion
Asked by
Brad
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Brad
Top achievements
Rank 1
Jan-Dirk
Top achievements
Rank 1
Steve
Telerik team
Share this question
or