Potato Hwang
Potato Hwang

Reputation: 309

How to lock the orientation with Sencha-touch?

My environment are used the Sencha-touch & PhoneGap. May I lock the orientation with Vertical. I don't want the user use the horizontal direction for operation.

launch: function() {
    // Destroy the #appLoadingIndicator element
    Ext.fly('appLoadingIndicator').destroy();

    // Initialize the main view
    Ext.Viewport.add(Ext.create('ebook.view.Main'));
},

I need add some control or config on lunch function? or I need Add the control to main.js. My purpose is I want to lock the orientation on "vertical direction". Have anyone can help me. thank you.

Other Reference: I found the below code on "package.json", I try to delete the "landscapeLeft"&"landscapeRight" and rebuild it got the same result. I can't lock the user orientation.

    /**
 * @cfg {Array[String]} orientations
 * @required
 * This is orientations that this application can run.
 */
"orientations": [
    "portrait",
    "landscapeLeft",
    "landscapeRight",
    "portraitUpsideDown"
]

Upvotes: 3

Views: 1852

Answers (3)

smarques
smarques

Reputation: 728

On Android and using Phonegap 3.3 the orientation preference in config.xml seems to get ignored. One workaround that worked for me was to modify AndroidManifest.xml and add the attribute android:screenOrientation="portrait" to each activity tag. Seems to work.

Upvotes: 2

Grgur
Grgur

Reputation: 7382

You should do that in PhoneGap's config.xml

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

Upvotes: 2

Qian JIN
Qian JIN

Reputation: 186

I'm not sure which platform you are developing on. My experience with Sencha+PhoneGap is mainly on iOS.

Since all the web content generated by Sencha will be wrapped inside a view controller (which is the mechanism of phonegap project). You can simply lock the orientation by removing all the landscape option in your project's .plist.

It works fine in one of my demo.

Upvotes: 0

Related Questions