12-30-2012 01:06 PM
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?
12-31-2012 01:29 AM
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:
- 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 !
12-31-2012 03:45 AM
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.