Swapnil Dhotre
Swapnil Dhotre

Reputation: 373

How to force camera to be in portrait mode using cordova / ionic app?

I am working on hybrid app, I am invoking camera from my app I want this camera to be in portrait mode only. I tried doing it by changing config file as:

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

But as camera open it starts rotation. How do I prevent it?

Upvotes: 4

Views: 1584

Answers (1)

V&#237;ctor
V&#237;ctor

Reputation: 3039

Exists a plugin to force orientation

https://github.com/gbenvenuti/cordova-plugin-screen-orientation

Just force portrait before entering camera mode, and disable it after exit.

// set to either landscape
screen.lockOrientation('landscape');

// allow user rotate
screen.unlockOrientation();

I dont know if this is going to work, because camera is native, but if you embed the camera in your app, works for sure.

Please post your results ;)

Upvotes: 1

Related Questions