Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Lock application orientation in Symbian

From Wiki
Jump to: navigation, search


Version Hint

Windows Phone: [[Category:Windows Phone]]
[[Category:Windows Phone 7.5]]
[[Category:Windows Phone 8]]

Nokia Asha: [[Category:Nokia Asha]]
[[Category:Nokia Asha Platform 1.0]]

Series 40: [[Category:Series 40]]
[[Category:Series 40 1st Edition]] [[Category:Series 40 2nd Edition]]
[[Category:Series 40 3rd Edition (initial release)]] [[Category:Series 40 3rd Edition FP1]] [[Category:Series 40 3rd Edition FP2]]
[[Category:Series 40 5th Edition (initial release)]] [[Category:Series 40 5th Edition FP1]]
[[Category:Series 40 6th Edition (initial release)]] [[Category:Series 40 6th Edition FP1]] [[Category:Series 40 Developer Platform 1.0]] [[Category:Series 40 Developer Platform 1.1]] [[Category:Series 40 Developer Platform 2.0]]

Symbian: [[Category:Symbian]]
[[Category:S60 1st Edition]] [[Category:S60 2nd Edition (initial release)]] [[Category:S60 2nd Edition FP1]] [[Category:S60 2nd Edition FP2]] [[Category:S60 2nd Edition FP3]]
[[Category:S60 3rd Edition (initial release)]] [[Category:S60 3rd Edition FP1]] [[Category:S60 3rd Edition FP2]]
[[Category:S60 5th Edition]]
[[Category:Symbian^3]] [[Category:Symbian Anna]] [[Category:Nokia Belle]]

Article Metadata
Keywords: CAknAppUi, EAppOrientationLandscape
Created: kratsan (25 May 2011)
Last edited: lpvalente (06 Sep 2012)


This example shows how to lock the application orientation to landscape.


  • Symbian SDK is installed


Option 1:

Lock the orientation when the UI is constructed in a CAknViewAppUi-derived class:

#include <aknViewAppUi.h>
#include <e32std.h>
class CMyAppUi : public CAknViewAppUi
// ...
void CMyAppui::ConstructL()
// Locks the orientation to landscape, similarly,
// use EAppOrientationPortrait to lock the orientation to portrait.

Option 2:

The UI is already constructed and the orientation lock must be applied afterwards. This option works similarly as is done in Qt implementations.

#include <eikappui.h>
#include <aknenv.h>
#include <aknappui.h>
// Place this code to appropriate function / method
CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
if (appUi) {
// Lock application orientation into landscape,
// similarly use CAknAppUi::EAppUiOrientationPortrait
// to lock the orientation to portrait.
// ...


The application orientation is locked to landscape, and it does not change even if the device orientation is changed by the user.

This page was last modified on 6 September 2012, at 15:04.
65 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.