如何在加载启动屏幕时停止Ipad屏幕方向?-在Flex Mobile应用程序中



我正在开发一个ipad应用程序,因为我在应用程序描述符xml中设置了应用程序纵横比为横向和自动定向为true,比如这个

<!-- 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>

默认情况下,我的应用程序加载在横向视图中,但当用户将ipad保持在"landscape_Left"视图中时,即ipad主页按钮面向用户的左手侧,然后启动屏幕旋转到"landscape_right",它看起来是上下颠倒的。然后,用户必须将ipad旋转180度才能直接看到应用程序,每次打开应用程序时都会出现这种情况。我无法阻止应用程序旋转到DEFAULT横向视图,我尝试在预初始化中将方向设置为ROTATE_LEFT,但它先旋转到DEFAULT,然后旋转到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>

这个问题有什么解决办法吗?。它甚至在调用应用程序构造函数之前就已经旋转了。

当您删除splashScreenImage属性并为不同方向提供启动图像时,这可能是可能的,例如:

Default-Landscape.png 
Default-Portrait.png 
Default-Landscape@2x.png
Default-Portrait@2x.png

最新更新