Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
bDev
Posts: 40
Registered: ‎12-14-2013
My Device: Playbook
My Carrier: Orange

changing screen orientation

Hi, how to change the screen display orientation based on display direction. 

Say I want to change the screen display to 180 when the displayDirection is pointing east. 

 

thanks for help.

Please use plain text.
Developer
BBSJdev
Posts: 6,094
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: changing screen orientation

You can use the sensors to detect the direct in this case the compass...

 

http://developer.blackberry.com/native/documentation/cascades/device_comm/sensors/

 

and the set the display orientation...

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__orientationsupport.html

 

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
New Developer
bDev
Posts: 40
Registered: ‎12-14-2013
My Device: Playbook
My Carrier: Orange

Re: changing screen orientation

thanks for guidance but couldn't find what i was looking for.

 

what i want is display screen orientation to stay unchanged even when the device physical direction changes,

 

say when the displayDirection changes from DisplayDirection.East to DisplayDirection.west, the device current screen orientation should not change.

 

the expected code might be something like this (taken from sensordemo)

if (displayDirection == DisplayDirection.East) {
                    compass.userOrientation = 90;

if (displayDirection == DisplayDirection.West) {
                    compass.userOrientation = 90;

 it should keep the screen display in the same 90 deg irrespective of the change in the displayDirection.

 

i tried this way but still find the screen to be changing with the change in device physical orientation, any idea what could be the missing part, thanks

Please use plain text.
Developer
saprykin
Posts: 271
Registered: ‎05-29-2013
My Device: BlackBerry Z10
My Carrier: MTS

Re: changing screen orientation

Have you tried to set orientation in bar descriptor file of your project?
-------------------------------------------------------------------------------
NSR Reader for BlackBerry 10 @NSRReader on Twitter
Me @xelfium on Twitter
Please use plain text.
Developer
BBSJdev
Posts: 6,094
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: changing screen orientation

Your second post is totally the opposite of the first post to stop orientation of the screen in the bar-descriptor.xml put this...

 

    <initialWindow>
        <autoOrients>false</autoOrients>
    </initialWindow>

 and in your qml put this...

 

OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.DisplayPortrait;

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
New Developer
bDev
Posts: 40
Registered: ‎12-14-2013
My Device: Playbook
My Carrier: Orange

Re: changing screen orientation

No no, I don't want to stop the orientation or anything like that. I just want to control the screen and put it with the screen pointing to device east all the time even when the device displaydirection changes, just like in the code I gave above.

Nothing to do with orientation property viz. portrait or landscape. I'm interested in displaydirection property
Please use plain text.
Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: changing screen orientation

If you are asking if you can lock the device orientation so other apps won't rotate, no, you can't do that. Otherwise, as said previously in the thread, if you don't want the screen orientation to change, lock it to the one you want.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Please use plain text.