Namespaces
Variants
Actions
Revision as of 18:04, 6 September 2012 by lpvalente (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Lock application orientation in Symbian

Jump to: navigation, search


Article Metadata

Compatibility
Platform(s): Symbian

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

Contents

Overview

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

Preconditions

  • Symbian SDK is installed


Source

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.
BaseConstructL(EAppOrientationLandscape);
}

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());
TRAPD(error,
if (appUi) {
// Lock application orientation into landscape,
// similarly use CAknAppUi::EAppUiOrientationPortrait
// to lock the orientation to portrait.
appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);
}
);
// ...

Postconditions

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

180 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved