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

Orientation Landscape and Reverse Landscape

3 Answers 1694 Views
Apache Cordova
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alfonso
Top achievements
Rank 1
Alfonso asked on 22 May 2014, 08:51 AM
Dir Sir/Madam,

I am trying to allow an app to rotate but only in landscape modes.

This is both for Android and IOS.

If we disable portrait mode in the project, then the app opens in landscape mode, but it does not rotate, so if I turn it 180ยบ, (reverse landscape) the app will be upside down. We need the app to rotate.
If we enable landscape, and portrait mode then it works in reverse landscape, but we don't know how to avoid the portrait modes.

Is there anyway to achieve this in Android and IOS.

Thanks in advance,

Best regards,

Alfonso de las Heras.

3 Answers, 1 is accepted

Sort by
0
Alfonso
Top achievements
Rank 1
answered on 22 May 2014, 09:08 AM
I have been able to do this on iOS:

function shouldRotateToOrientation(orientation) {
//    alert(orientation);

    switch (orientation) {
        case 0:
            return false;
        case 180:
            console.log("Portrait");
            return false;
            //LandscapeRight or LandscapeLeft
        case 90:
            return true;
        case -90:
            console.log("Landscape");
            return true;
    }
    
}




But i don't know how to do the same in Android.

Thanks.
0
Accepted
Tsvetomir
Telerik team
answered on 23 May 2014, 06:31 AM
Hello Alfonso,

You can enable landscape and reverse landscape screen orientation by performing these steps:
  • Go to Project Properties and disable portrait mode
  • For iOS:
    • Open iOS Config.xml (Right click on Project -> Edit Configuration)
    • Add this preference : <preference name="orientation" value="landscape" />, you can find more information in the orientation segment here.
  • For Android (the steps below will be available in the 2.2 release of AppBuilder, scheduled for two weeks from now)
    • Open Android Manifest.xml (Right click on project -> Edit Configuration)
    • In the activity element add this android:screenOrientation="sensorLandscape", you can find more information about android screen orientations here.

I hope this helps.

Kind Regards,
Tsvetomir
Telerik
 

Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

 
0
Alfonso
Top achievements
Rank 1
answered on 23 May 2014, 06:56 AM
Thank you Tsvetomir,

Those steps worked for the iOS version.
We will wait for the 2.2 version of apppbuilder to test it on Android.

Thank you very much for your help.

Best regards,

Alfonso.
Tags
Apache Cordova
Asked by
Alfonso
Top achievements
Rank 1
Answers by
Alfonso
Top achievements
Rank 1
Tsvetomir
Telerik team
Share this question
or