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
Trusted Contributor
marcelnijman
Posts: 118
Registered: ‎06-19-2012
My Device: PlayBook + Red Z10 + BB10 Dev Alpha C

setting allowed orientations

Where is the preferred place to call OrientationSupport::instance()->setSupportedDisplayOrientation() ?

 

Since this is a global setting, it should be called only when the *visible* page changes, not anytime the top page of any navigation stack changes. Are there signals which are triggered when a page becomes visible/invisible?

 

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: setting allowed orientations

there is no such event.

 

if it is for a navigation pane, your best bet is with the onTopChanged event as documented. for other use cases, it will be based on your specific context...

 

i've used it on the following events/scenarios so far:

- onCreationCompleted

- onTopChanged

- before calling a native app Invoke, and after native app Invoke is closed (media player for example)

- tab.onTriggered or onActiveTabChanged

 

it is definitely annoying to have to set this value everytime but after some thought, i find that it also gives much flexibility, which is good !

Please use plain text.
Trusted Contributor
marcelnijman
Posts: 118
Registered: ‎06-19-2012
My Device: PlayBook + Red Z10 + BB10 Dev Alpha C

Re: setting allowed orientations

But onTopChanged is also called from navigation panes which are not *currently* part of the view hierarchy! For example, when you are preparing a modal sheet, which contains its own navigation pane. And even in the current viev hierarchy there may be multiple navigation panes, (for instance, in tabbed panes).

 

Have you run into these complications?

 

How can I deal with this in a generic way? I have a feeling that this has not been well thought througt by RIM. Compare this to viewWillAppear and viewWillDisappear in iOS, which gives you directly what you want, even though in iOS it's not used for rotation. The reason to have a generic solution is for more than just rotation. For instance, you migth want to start/stop a timer depending on the visibility of a pane, you may want to turn on/off logging, or auto log in/out when a pane becomes visible/invisible.

 

My app does all of this (log in/out of a chess server, start/stop game clock, set the allowed orientations), and I have not yet found a fool-proof way dealing with this.

 

Please use plain text.