1

i'm developing an ipad app, in that i setted the application aspect ratio to landscape and auto orients true in application descriptor xml, like this

<!-- The initial aspect ratio of the app when launched (either "portrait" or "landscape"). Optional. Mobile only. Default is the natural orientation of the device -->

<aspectRatio>portrait</aspectRatio>
<autoOrients>false</autoOrients>

By default my application loads in landscape view, but when user holds the ipad in "Landscape_Left" view i.e ipad-home-button facing left hand side of the user, then the splash screen rotate to "Landscape_right" it looks upside down. Then the user have to rotate the ipad 180 degree to see the app in straight view, this happens every time while opening the application. I can't able to prevent the app from rotating to DEFAULT Landscape view, i tried setting the orientation to ROTATED_LEFT in preinitialize but its rotating to DEFAULT then to LEFT.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160"
           addedToStage="application1_addedToStageHandler(event)"
           preinitialize="application1_preinitializeHandler(event)"
           creationComplete="application1_creationCompleteHandler(event)"
           backgroundColor="#333A42"
           splashScreenImage="@Embed('assets/app_logo.png')"
           splashScreenMinimumDisplayTime="3000" >

<fx:Script>
    <![CDATA[
        import mx.events.FlexEvent;
        import mx.managers.ISystemManager;


        protected function application1_addedToStageHandler(event:Event):void
        {
            // TODO Auto-generated method stub
            trace("Orientation ::"+this.stage.orientation);
        }

        protected function application1_preinitializeHandler(event:FlexEvent):void
        {
            // TODO Auto-generated method stub
            trace("Aspect Ratio ::"+this.aspectRatio);
            var calAR:String = this.width > this.height ? StageAspectRatio.LANDSCAPE : StageAspectRatio.PORTRAIT;
            trace("Calculate Aspect Ratio ::"+calAR);
            var sm:ISystemManager = systemManager;

            if (sm && sm.stage && sm.isTopLevelRoot())
            {
                //                  sm.stage.addEventListener("orientationChanging", stage_orientationChangingHandler);
                //                  sm.stage.addEventListener("orientationChange", stage_orientationChange);
                trace("System manager Orientation ::"+sm.stage.orientation);
                trace("System manager Device Orientation ::"+sm.stage.deviceOrientation);
                sm.stage.setOrientation(StageOrientation.ROTATED_LEFT);
                sm.stage.setAspectRatio(StageAspectRatio.LANDSCAPE);
            }
        }

        protected function application1_creationCompleteHandler(event:FlexEvent):void
        {
            var sm:ISystemManager = systemManager;

            if (sm && sm.stage && sm.isTopLevelRoot())
            {
                trace("System manager Orientation ::"+sm.stage.orientation);
                trace("System manager Device Orientation ::"+sm.stage.deviceOrientation);
            }
        }

    ]]>
</fx:Script>

<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:BorderContainer  height="300" horizontalCenter="0" verticalCenter="0">
    <s:VGroup horizontalAlign="center">
        <s:TextInput id="txtAspectRatio"/>
        <s:Button label="Test" click="{txtAspectRatio.text = this.stage.orientation}"/>
    </s:VGroup>

</s:BorderContainer>
</s:Application>

Is there any fix for this issue ?. Its rotating even before the Application constructor is invoked.

ketan
  • 19,129
  • 42
  • 60
  • 98
Gowtham S
  • 923
  • 14
  • 39

1 Answers1

0

This might be possible, when you remove splashScreenImage attribute and Provide Launch Images for Different Orientations, like:

Default-Landscape.png 
Default-Portrait.png 
Default-Landscape@2x.png
Default-Portrait@2x.png
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416